Google Ads refresh token expires after an hour

103 views
Skip to first unread message

Nathaniel John

unread,
Jul 21, 2025, 9:45:43 AM7/21/25
to Google Ads API and AdWords API Forum
Please, I need help, I keep getting this error on my production app after every 1 hour or thereabout.
Client error: `POST https://oauth2.googleapis.com/token` resulted in a `400 Bad Request` response: { "error": "invalid_grant", "error_description": "Token has been expired or revoked." }
I've been investigating this for months and am yet to resolve it.
When it happens like this, I would manually have to do the whole Oauth process again to get a new one refresh token to continue.
I'm using the PHP Google Ads API library v20,  in my laravel backend.

Funny enough, I don't experience it in my development environment.
I've been connected on my development for months now, and I've never experience this error.
Please, I will appreciate your help and advice on how to solve this.

Google Ads API Forum Advisor

unread,
Jul 21, 2025, 1:11:53 PM7/21/25
to nathaniel....@gmail.com, adwor...@googlegroups.com
Hi,

Thank you for reaching out to the Google Ads API support team.

The "invalid_grant" error. occurs when 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. Your Google project's publishing status is Testing so the refresh token expires every 7 days and receives an invalid_grant error.

You can follow the following steps to avoid this issue:

  • Go to the Google API Console and navigate to the OAuth consent screen
  • Change the publishing status to “In production

Additionally, the invalid_grant error usually indicates an issue with the refresh token. That said, you’ll need to regenerate credentials and refresh tokens. You may refer to this document to read more information about refresh token expiration.

Note that the access token will expire in 1 hour. You can use the refresh token to refresh an expired access token. By default, our client libraries automatically refresh expired access tokens.

Since you are using the PHP client library, you may refer to this sample code to generate user credentials. Once you have a valid refresh token, the error should disappear.

If the issue still persists even after the above suggestions, kindly share the latest complete API logs (request and response with request-id and request header) generated at your end. Refer to the PHP guide to enable logging at your end. 

You can send the details via Reply privately to the author option, or direct private reply to this email.

Thanks,
 
Google Logo Google Ads API Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5
[2025-07-21 17:11:10Z GMT] This message is in relation to case "ref:!00D1U01174p.!500Ht01swEf4:ref" (ADR-00319613)



Reply all
Reply to author
Forward
0 new messages