Search code examples
google-analyticsgoogle-apigoogle-developers-consolegoogle-developer-toolsoauth2-playground

'Token has been expired or revoked' - Google OAuth2 Refresh token gets expired in a few days


I am using Google Analytics API to fetch analytics data. I tried to authenticate it using following steps:

  • Created OAuth client ID in https://console.developers.google.com/ credentials section.
  • In consent screen I had set publishing status as testing
  • In OAuth 2.0 Playground I got the refresh token using above generated client id and client secret
  • Then I am using it to generate access token through it.

But after a few days, the refresh token expires although it is mentioned that the refresh token's validity is life long.


Solution

  • If your app is in testing mode then user tokens will expire in 7 days. Please find this explanations here: https://support.google.com/cloud/answer/10311615#zippy=%2Ctesting enter image description here