简体   繁体   English

Google OAuth和本地开发者

[英]Google OAuth and local dev

i am trying to use Google OAuth to import a user 's contacts. 我正在尝试使用Google OAuth导入用户的联系人。 In order to get a consumer and secret key for you app you have to verify your domain at https://www.google.com/accounts/ManageDomains Google allows you to use only domains without ports. 为了获取您的应用消费者和密钥,您必须通过https://www.google.com/accounts/ManageDomains验证您的域名Google允许您仅使用没有端口的域名。 I want to test and build the app locally so usually (Facebook, Linkedin apps) i user a reverse SSH tunnel for example http://6pna.com:30002 我想在本地测试和构建应用程序通常(Facebook,Linkedin应用程序)我使用反向SSH隧道,例如http://6pna.com:30002

Has anyone use a tunnel with Google OAuth. 有没有人使用Google OAuth隧道。 Does it work? 它有用吗? So far I just verified my apps domain but my requests come from the tunnel (different domain) so OAuth fails (although i get to Google and authorize my app) 到目前为止,我刚刚验证了我的应用域名,但我的请求来自隧道(不同的域名),因此OAuth失败(尽管我访问Google并授权我的应用)

Any tips, hints ? 任何提示,提示? Thanks 谢谢

经过反复试验后,我发现请求的域名无关紧要

i just use the official gdata google auth library http://code.google.com/p/gdata-python-client 我只使用官方的gdata google auth库http://code.google.com/p/gdata-python-client

Here is some code 这是一些代码

    google_auth_url = None
    if not current_user.gmail_authorized:
        google = gdata.contacts.service.ContactsService(source=GOOGLE_OAUTH_SETTINGS['APP_NAME'])
        google.SetOAuthInputParameters(GOOGLE_OAUTH_SETTINGS['SIG_METHOD'], GOOGLE_OAUTH_SETTINGS['CONSUMER_KEY'],
                                      consumer_secret=GOOGLE_OAUTH_SETTINGS['CONSUMER_SECRET'])
        if not request.vars.oauth_verifier:
            req_token = google.FetchOAuthRequestToken(scopes=GOOGLE_OAUTH_SETTINGS['SCOPES'],
                          oauth_callback="http://"+request.env.http_host+URL(r=request,c='default',f='import_accounts'))
            session['oauth_token_secret'] = req_token.secret
            google_auth_url = google.GenerateOAuthAuthorizationURL()
        else:
            oauth_token = gdata.auth.OAuthTokenFromUrl(request.env.request_uri)
            if oauth_token:
                oauth_token.secret = session['oauth_token_secret']
                oauth_token.oauth_input_params = google.GetOAuthInputParameters()
                google.SetOAuthToken(oauth_token)
                access_token = google.UpgradeToOAuthAccessToken(oauth_verifier=request.vars.oauth_verifier)
                # store access_tonen

        #google.GetContactsFeed() # do the process or do it in ajax (but first update the user)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在本地开发服务器上的Google Appengine后端日志记录 - Google Appengine backend logging on local dev server Google云端存储客户端无法在本地dev_server上运行 - Google Cloud Storage Client not working on local dev_server Google App Engine NDB-游标可在本地开发人员上使用,但不适用于生产环境 - Google App Engine NDB - Cursor on query working on local dev but not in production 本地开发服务器的Google App Engine没有终端输出? - No terminal output for google app engine for local dev server? 使用python在本地机器上使用Oauth 2连接到谷歌驱动器时出错 - Error connecting to google drive using Oauth 2 on local machine with python 如何使用google oauth将所有文件从google bucket目录下载到本地目录 - How to download all files from google bucket directory to local directory using google oauth 从Google App Engine dev_appserver获取非本地主机名 - Get non-local host name from Google App Engine dev_appserver Google Cloud Composer:如何从本地开发机器触发 DAG 运行? - Google Cloud Composer: How to trigger a DAG Run from a local dev machine? 运行google app sdk dev_appserver.py找不到本地python环境 - Running google app sdk dev_appserver.py can't find the local python environment 用于本地开发服务器重定向到登录页面的Google App Engine远程api - google app engine remote api for local dev server redirecting to login page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM