1ap / google-api-python-client

Automatically exported from code.google.com/p/google-api-python-client
Other
0 stars 0 forks source link

Retrieving refresh_token results in "invalid grant" error #187

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Try to refresh an access token using a refresh token as defined in 
https://developers.google.com/accounts/docs/OAuth2WebServer#refresh

What is the expected output? What do you see instead?
Response with status 200, containing a new access token.

Instead, I get a response with {"error": "invalid_grant"} json dict, and with 
status 400.

What version of the product are you using? On what operating system?
google_api_python_client-1.0c3

Please provide any additional information below.

Here's the details of the POST request:
url = https://accounts.google.com/o/oauth2/token
headers = {'content-type': 'application/x-www-form-urlencoded'}
data = {
  'client_id': '...',
  'client_secret': '...',
  'grant_type': 'refresh_token',
  'refresh_token': '...'
}

It returns this JSON:
{'error': 'invalid_grant'}

What does "invalid grant" error mean in this case? It seems that I'm passing 
all the data and headers required by 
https://developers.google.com/accounts/docs/OAuth2WebServer#refresh. Or are any 
parameters missing or incorrect?

Original issue reported on code.google.com by nakti...@gmail.com on 3 Sep 2012 at 4:57

GoogleCodeExporter commented 8 years ago
This probably can be closed, the response was probably a result of a revoked 
token. Since "invalid_grant" (per specification) can mean many things - it was 
quite difficult to debug. But I guess revoked key should have been the case.

Original comment by nakti...@gmail.com on 4 Sep 2012 at 1:14

GoogleCodeExporter commented 8 years ago

Original comment by jcgregorio@google.com on 4 Sep 2012 at 1:22