Google-api-php-client: Service account example fails with "invalid grant" exception

Created on 2 Sep 2014  路  2Comments  路  Source: googleapis/google-api-php-client

Running the example examples/service-account.php, it ends with:

Fatal error: Uncaught exception 'Google_Auth_Exception' with message 'Error refreshing the OAuth2 token, message: ' in google/apiclient/src/Google/Auth/OAuth2.php on line 327

Google_Auth_Exception: Error refreshing the OAuth2 token, message: '{
  "error" : "invalid_grant"
}' in google/apiclient/src/Google/Auth/OAuth2.php on line 327

Call Stack:
    0.0020     262920   1. {main}() service-account:0
    0.0155    3907760   2. Google_Auth_OAuth2->refreshTokenWithAssertion() service-account.php:77
    0.0201    3913072   3. Google_Auth_OAuth2->refreshTokenRequest() google/apiclient/src/Google/Auth/OAuth2.php:289
triage me

Most helpful comment

I'm getting the same error, but I didn't found the solution

All 2 comments

It seems the error comes from a wrong variable name: I provided a wrong $client_id. Developers should use the Email address provided in the console instead of the client id

I'm getting the same error, but I didn't found the solution

Was this page helpful?
0 / 5 - 0 ratings