invalid_grant in Google OAuth Client
The Google authentication was working perfect when ran locally. However wasn’t working and was throwing invalid_grant AccessTokenRefreshError Exception.
After literally scratching head for hours, and digging into stackoverflow and wherever possible, finally figured out the solution.
Thought this would help in future for all fellow developers.
Please make sure these things are fine with your deployment (I was trying to authenticate with Service Account)
1. Use Service Client Email, not the ID
2. Make sure the time is synced with NTP, otherwise it expires the token before being used. (This was the actual error)
3. Some libraries do not support PKCS12 key. Covert it to PEM and remove the extra lines before the certificate.
4. Make sure the service account has necessary permissions granted.
(PS: If anything else, please reply so that I can include those as well.)











