[英]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.