Refresh Token Expiration Problem

7,262 views
Skip to first unread message

Marwen HMIDI

unread,
Jun 29, 2022, 11:17:10 AM6/29/22
to Google Ads API and AdWords API Forum
Hello google ads api team
I'm extracting data from google ads api And I encountred this issue: 
google.auth.exceptions.RefreshError: ('invalid_grant: Token has been expired or revoked.', {'error': 'invalid_grant', 'error_description': 'Token has been expired or revoked.'})
The cause of this problem is that I'm using a test account (it expires after 7 days).

Is there a way to avoid this ? ( get a refresh token without expiration date or another way to
access the google ads api that doesn't cause this issue ? / or migrating from test account
to prod account)

Thank you everyone,
Marwen 

Google Ads API Forum Advisor

unread,
Jun 29, 2022, 12:26:13 PM6/29/22
to adwor...@googlegroups.com
Hi,

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

Moving forward, it appears that you've encountered the invalid_grant error. It means that the token has been expired or revoked. The common cause of this error is when 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 resolve or avoid this error you need to do this, in your Google project you set the publishing status to "Testing" so the refresh token expires every 7 days and receives an “invalid_grant” error. Go to the Google API Console and navigate to the OAuth consent screen. Then change the publishing status to “In production”. But please note that there are different reasons why the refresh token is expiring and you can see it on this document.

However, since the issue is more specific to refresh tokens, then I would suggest reaching out to the more equipped team for this concern via this link.

Thanks,
Google Logo
Nirmitabahen Gaurav
Google Ads API Team
 


ref:_00D1U1174p._5004Q2cEW4w:ref

pmoe...@binaerpark.de

unread,
Jun 30, 2022, 4:53:00 PM6/30/22
to Google Ads API and AdWords API Forum
I have the same problem.

The problem with state 'in production' is that a lot of stuff is required (what makes sense if it really is public and in production).
But we just use it internally and only from one account,
A service account would make more sense but is only available for Google workspace customers.

Patrik

Google Ads API Forum Advisor

unread,
Jun 30, 2022, 10:34:40 PM6/30/22
to pmoe...@binaerpark.de, adwor...@googlegroups.com
Hi all,

Thank you for reaching us out. I am Sherwin from Google Ads API support team and I work with Nirmita. I hope that all of you are doing well today.

@Patrik. I really understand where you are coming from. We really appreciate your comments regarding setting up the oauth however, that is the process that we need to follow. Since you are concerned about it, what we can do is to advise you to reach out to the Google Cloud support team regarding your comments on Oauth setup because they are most equipped regarding this.

Kind regards,
Google Logo
Sherwin Vincent
Google Ads API Team
 


ref:_00D1U1174p._5004Q2cEW4w:ref
Reply all
Reply to author
Forward
0 new messages