Google API refresh token has been expired or revoked

Viewed 5473

I am using a Google Ads php library (https://github.com/googleads/googleads-php-lib) to manage my own google ads account, following Google's instructions here (https://developers.google.com/adwords/api/docs/guides/first-api-call)

(I've actually been doing this for many years without a problem, but I recently switched over to using a different project in the Google Cloud Platform, so I had to update my credentials and get a new refresh token)

To get a new refresh token, I ran the php script called GetRefreshTokenWithoutIniFile.php (which allows me to grant offline access and retrieve a new refresh token, which I store in a file auth.ini for future use).

The refresh token last for a few days, before I see this error:

{
    "error" : "invalid_grant",
    "error_description" : "Token has been expired or revoked."
}

I have been using the above method for years and the refresh token has never expired. However, it now seems to expire every couple of days. I am certainly not 'running out' of refresh tokens (I only request one), and the user is not revoking access (the user is me). For that reason, these similar answers don't help me:

Any more ideas?

1 Answers

UPDATE: This did not solve the problem

According to Token has expired or revoked - Google Ads, a refresh token won't persist unless the app is in 'production' mode.

The recommended solution is to select "Publish App" from the Google API console. I tried this out, but unfortunately, after a few days of using the refresh token successfully, the refresh token has expired again.

Related