0

i have a very weird problem. I'm using the Google authentication API since moree than one month now and all working perfect. But now out of the sudden, my users can't get refresh token anymore. My app is on testing state, so i thought the refreesh token my testing user was having is expired after 7 days, but then i tried to get another refresh token by doing thee authorization from the beginning to receive a code that i use to get a refresh tokn. But no chance i'm only receiving this response back: Status code 400 { "error": "invalid_grant", "error_description": "Bad Request" }

Thank you very much for your help!

shakatechi
  • 51
  • 3
  • 1
    How are you getting the refresh token? Consider providing the relevant parts of the code you're using. – Iamblichus Sep 16 '22 at 08:26
  • Well the user clicks on the button that is forwarding him/her to the oauth consent screen where the user checks all the premissions for the scopes. after confirming the user end up in my URI page where i have a workflow that is storaging the code and then using it in api call: https://oauth2.googleapis.com/token to get a refresh token. In the past everything worked perfectly but just out of the suddon i'm facing this challenge now – shakatechi Sep 16 '22 at 08:32
  • 1
    please edit your question and include [example] – Linda Lawton - DaImTo Sep 16 '22 at 08:51

1 Answers1

1

A Google Cloud Platform project with an OAuth consent screen configured for an external user type and a publishing status of "Testing" is issued a refresh token expiring in 7 days.

To stop your refresh tokens from expiring set it to production.

enter image description here

Why cant you refresh after seven days

What i am writing here is my opinion only from experience. There is no documented proof of any of this from googles side.

After seven days your refresh token will expire, but the question is how is google expiring these refresh tokens. From what i can see they are not using the normal method of expiring the refresh token. They are in fact revoking the users granted access on the google account. So the all of the refresh tokens granted will stop working at once.

So why are you having issues with the client library. Normally the way the client libraries were originally designed. if the refresh token expired it would prompt the user to authorize the app again. This does not happen with the seven day revoke method. IMO because the error message is different, and the libraries have not been updated to take this into account, and prompt for access again. The only way to fix it is to delete the old stored refresh token and request a new one.

So your not able to receive new refresh tokens because your code is stuck with the old one. Make sure to hard delete any old refresh tokens you have stored. They wont work and the library doesnt understand how to delete them on its own.

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449