i correctly scoping offline access , storing that. every 60 minutes, when needed, retrieve new access_token. code has not changed, odd when first went through authorization.
client_id ="xxxxx.apps.googleusercontent.com" client_secret ="xxxxxxxxxxxxxxxxxxxx" refresh_token ="xxxxxxxxxxxxxxxxxxx" response = oauth2a.refreshtoken(client_id,client_secret,refresh_token) def refreshtoken(client_id, client_secret, refresh_token): params = {} params['client_id'] = client_id params['client_secret'] = client_secret params['refresh_token'] = refresh_token params['grant_type'] = 'refresh_token' request_url = accountsurl('o/oauth2/token') response = urllib.urlopen(request_url, urllib.urlencode(params)).read() return json.loads(response)
the response {u'error': u'invalid_grant'}. have attempted on 3 different machines,and httperror: http error 400: bad request
thank you
invalid_grant error has 2 common causes.
- your server’s clock not in sync ntp. (solution: check server time if incorrect fix it. )
- the refresh token limit has been exceeded. (solution: nothing can cant have more refresh tokens in use) applications can request multiple refresh tokens. example, useful in situations user wants install application on multiple machines. in case, 2 refresh tokens required, 1 each installation. when number of refresh tokens exceeds limit, older tokens become invalid. if application attempts use invalidated refresh token, invalid_grant error response returned. limit each unique pair of oauth 2.0 client , 25 refresh tokens (note limit subject change). if application continues request refresh tokens same client/account pair, once 26th token issued, 1st refresh token issued become invalid. 27th requested refresh token invalidate 2nd issued token , on.
Comments
Post a Comment