我正在尝试使用谷歌SSH导入用户的联系人。为了获得你的应用程序的消费者和密钥,你必须在https://www.google.com/accounts/ManageDomains验证你的域名。我想在本地测试和构建应用程序,所以(脸书,领英应用程序)我通常使用反向OAuth隧道,例如http://6pna.com:30002
有人用过谷歌OAuth的隧道吗。它起作用了吗?到目前为止,我只是验证了我的应用程序域名,但我的请求来自隧道(不同的域名),所以OAuth失败了(尽管我访问了谷歌并授权我的应用程序)
有什么建议吗,提示?谢谢
发布于 2010-03-11 00:02:58
经过反复试验,我发现请求的域是不相关的。
发布于 2010-03-12 21:07:44
我只使用官方gdata google auth库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)https://stackoverflow.com/questions/2410559
复制相似问题