Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Cloud - oauth2client.client.HttpAccessTokenRefreshError: invalid_grant

I got this error message when trying to execute Google Prediction API.

raise HttpAccessTokenRefreshError(error_msg, status=resp.status)
oauth2client.client.HttpAccessTokenRefreshError: invalid_grant

My credential details

{
    "scopes": [],
    "private_key": "XXXXX",
    "id_token": null,
    "token_uri": "https://accounts.google.com/o/oauth2/token",
    "token_info_uri": null,
    "token_response": null,
    "client_id": null,
    "scope": "https://www.googleapis.com/auth/prediction https://www.googleapis.com/auth/devstorage.read_only",
    "token_expiry": null,
    "_class": "SignedJwtAssertionCredentials",
    "refresh_token": null,
    "_module": "oauth2client.client",
    "private_key_password": "notasecret",
    "access_token": null,
    "service_account_name": "[email protected]",
    "invalid": false,
    "assertion_type": null,
    "kwargs": {},
    "client_secret": null,
    "revoke_uri": "https://accounts.google.com/o/oauth2/revoke",
    "user_agent": null
}
like image 574
Nurdin Avatar asked Feb 16 '16 18:02

Nurdin


1 Answers

For future readers of this question, if this issue happens locally it can be caused by an out of sync system clock. Otherwise, this was also a known issue on App Engine at around the same time this question was posted. Details of both causes can be found in an issue report on the oauth2client GitHub project page from last year:

oauth2client.client.HttpAccessTokenRefreshError: invalid_grant: Bad Request

like image 76
Adam Avatar answered Nov 04 '22 17:11

Adam