views:

281

answers:

4

Hi guys, i am trying to use Google OAuth to import a user 's contacts. 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. 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

Has anyone use a tunnel with 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)

Any tips, hints ? Thanks

A: 

Hi anybody know working examples(source code) where oauth google works? I tryed code http://oauth.net/code/ but it does not work for me. I register google app, i safe to web config consumer key etc.

John
A: 

well after trial and error i found out that the request 's domain is irrelevant

PanosJee
A: 

How you find this? Do you have source code of google oauth? please share it? Which open source library you use?

John
+1  A: 

i just use the official gdata google auth library 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)
PanosJee