1
votes

!Screenshot of Error Getthing Error refreshing the OAuth2 token, message: '{ "error" : "invalid_grant" }' when trying to access Google Analytics API

  • This is a service account
  • I have specified my client ID, gservice account email, and the path to the certificate file
  • I have added the gservice account email as an admin to my Google Analytics profile
  • I have installed NTP on my ubuntu server to ensure that the time is correct

I am using a package ( https://github.com/thujohn/analytics-l4 ) but I don't think this is related to the issue at all.

Any ideas?

2

2 Answers

1
votes

There could be several causes for invalid_grant, for example, the assertion is a malformed JWT, or some required fields are missing, or Google fails to validate the signature of the assertion, etc. Seems that you were using the Google OAuth2 client library for PHP so the first two issues should be eliminated. Is it possible you used an incorrect private key file?

0
votes

Resolved the same issue by changing the scope