【问题标题】:Google OAuth and local devGoogle OAuth 和本地开发
【发布时间】:2011-01-25 12:24:19
【问题描述】:

我正在尝试使用 Google OAuth 导入用户的联系人。为了获得您的应用程序的使用者和密钥,您必须在https://www.google.com/accounts/ManageDomains 验证您的域,Google 允许您仅使用没有端口的域。我想在本地测试和构建应用程序(Facebook、Linkedin 应用程序)我使用反向 SSH 隧道,例如 http://6pna.com:30002

有没有人通过 Google OAuth 使用隧道。它有效吗?到目前为止,我刚刚验证了我的应用程序域,但我的请求来自隧道(不同的域),因此 OAuth 失败(尽管我访问了 Google 并授权了我的应用程序)

任何提示,提示?谢谢

【问题讨论】:

    标签: python oauth google-contacts-api


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      我只是使用官方的 gdata google auth library http://code.google.com/p/gdata-python-client

      这是一些代码

          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)
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2010-10-22
        • 1970-01-01
        • 2010-10-14
        • 1970-01-01
        • 1970-01-01
        • 2021-12-24
        相关资源
        最近更新 更多