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?

Tag:google-ads-api, google-api, oauth, refresh-token

2 comments.

  1. IanS

    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.

    1. Yan F.

      Perhaps the token expired because it was issued when your app was in development mode. Once you published the app, try deleting your saved OAuth response and recreating it (authorize the app again). The refresh token in this response should not be expiring as long as you keep using it.

Add a new comment.