2010-03-09 58 views
4

我想使用谷歌的OAuth導入用戶的聯繫人。爲了讓消費者和祕密密鑰對您應用程式需要驗證您的域名在https://www.google.com/accounts/ManageDomains谷歌可以讓你只使用域而不端口。我想在本地測試和構建應用程序(Facebook,LinkedIn應用程序),例如我使用反向SSH隧道,例如http://6pna.com:30002谷歌的OAuth和本地開發

是否有人使用Google OAuth的隧道?它工作嗎?到目前爲止,我只是驗證我的應用程序域,但我請求來自隧道(不同領域)這樣的OAuth失敗(雖然我到谷歌,並授權我的應用程序)

任何提示,提示?由於

回答

4

經過反覆試驗以及我發現了該請求的域名是無關緊要的

3

我只是用官方的谷歌gdata的權威性庫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)