Question

I am attempting to retrieve both access and refresh tokens for an application to access a fusion table of mine. I am using the OAuth 2.0 method and simply need to allow users who visit my application to INSERT records into my fusion table.

The problem I am encountering is when running the python script described by Google here. The error I receive when running the code out of the box (in PyDev, with Python 2.7 interpreter) is:

Traceback (most recent call last):
File "\\..\OAuthToken\root\oauth_tokens.py", line 59, in <module>
    redirect_uri)
  File "\\..\OAuthToken\root\oauth_tokens.py", line 41, in retrieve_tokens
    refresh_token = tokens['refresh_token']
KeyError: 'refresh_token'

Does anybody have a solution for me? I read somewhere on GitHub ( github.com/ff0000/red-social-auth/issues/3 - I'm not allowed to post anymore links) something to do with refresh_tokens being semi-retired, but clearly I'm just grasping at straws at this point.

Thanks for the help.

Était-ce utile?

La solution

So I was having the same issue as stated in the original question and was coming up with nothing. But then I found this, specifying that the original request needed to have access_type=offline so that a refresh token was sent. So I added that to Kathryn's oauth_tokens script like so.

Edited line 17:

  print '%s?client_id=%s&redirect_uri=%s&scope=%s&access_type=offline&response_type=code' % \

Well I thought this would solve my problem but it did not. I guess since the application initially registered with the default access type of "online" it would not grant a refresh token. This was solved by revoking access to the application under the Google account settings page.

Accounts -> Security -> Authorizing applications and sites -> Edit

I hope this helps someone as this was driving me nuts for a while.

I have added the script I am using on Github: https://github.com/mejackreed/fusion-tables-oauth-tokens/blob/master/oauth.py

Autres conseils

I'm not able to reproduce the problem, which makes this difficult to diagnose. Can you simply print out the response in line 38 to see what is actually being returned? This might give some clues to what the problem is.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top