google / gmail-oauth2-tools

Tools and sample code for authenticating to Gmail with OAuth2
Apache License 2.0
405 stars 211 forks source link

oauth2.py: Bad Request error, invalid grant #29

Closed robertsawko closed 3 years ago

robertsawko commented 4 years ago

I've been using oauth2.py script for the last couple of months but this week it started tripping over. I have been able to debug it a little, but it seems the problem is with the server connection.

~/bin/oauth2.py \
    --user=abc@gmail.com \
    --client_id=*** \
    --client_secret=*** \
    --refresh_token=***

When I print respone variable I get:

{u'error_description': u'Bad Request', u'error': u'invalid_grant'}

I recreated the refresh token, but the problem remains. Please advise.

Rodaxfck commented 4 years ago

Same for me :(

HTTPError: HTTP Error 400: Bad Request

Since 14/07 between 16:28 and 22:28 CEST

Edit : even with the doc https://developers.google.com/android-publisher/authorization#using_the_refresh_token with POST on https://accounts.google.com/o/oauth2/token?grant_type=refresh_token&client_id={CLIENT_ID}&client_secret={CLIENT_SECRET}&refresh_token={REFRESH_TOKEN}

I have { "error": "invalid_grant", "error_description": "Token has been expired or revoked." }

Edit 2 : i solved my problem by generating a new refresh token ... but i don't understand the issue because I thought refresh token will never expire

robertsawko commented 3 years ago

Yes. I am going to close this, but I had the same fix and the same impression as you did, @Rodaxfck .