Im using python (django framework) to gain a request token from google api, but the request token always comes back empty

StackOverflow https://stackoverflow.com/questions/8937148

Frage

Here is sample code that I'm working with.

def index(request):                     
flow = OAuth2WebServerFlow(
        client_id='xyz.apps.googleusercontent.com',
        client_secret='xyz',
        scope='https://www.googleapis.com/auth/plus.me',
        user_agent='sample/1.0')

callback = 'http://%s/oauth2callback' % request.META[ 'HTTP_HOST' ]
authorize_url = flow.step1_get_authorize_url(callback)

return HttpResponse(flow)

For some reason 'flow' is always set to " " or empty instead of a request token. I have searched for days on this issue. Can anyone tell me why I can't get a request token from google using this method?

fyi: I know that I should be redirecting the user to the authorize url, but I want to see if flow is set before I do since Google will provide the authorize url even if a request token wasn't returned.

War es hilfreich?

Lösung

Before you can use OAuth 2.0, you must register your application using the Google APIs Console. After you've registered, go to the API Access tab and copy the "Client ID" and "Client secret" values, which you'll need later.

http://code.google.com/p/google-api-python-client/wiki/OAuth2#Registering

If this answer actually helps with your problem then I must bid an R.I.P. to S.O.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top