Refresh error: invalid grant suddenly

121 views
Skip to first unread message

Alex Papageorgiou

unread,
Nov 21, 2024, 7:09:20 AM11/21/24
to Google Ads API and AdWords API Forum
Hi everyone,

After several years of seamless access to the API, I’ve suddenly started encountering the following error:

RefreshError: ('invalid_grant: Bad Request', {'error': 'invalid_grant', 'error_description': 'Bad Request'})

A few key points to note:

  • The publishing status has been set to In production since the beginning and hasn’t been changed.
  • I used the API regularly (at least once a week) for the past two years. However, I haven’t used it at all since April 2024, meaning there’s been over six months of inactivity.
  • No other settings have been altered, including those for the Cloud account, Google Ads MCC, etc.

Here’s how my yaml file looks like, which I pass to client = GoogleAdsClient.load_from_storage()

developer_token: xxxx.......
client_id: xxxxx.......apps.googleusercontent.com
client_secret: xxxx.......
refresh_token: xxxxxxxx........
use_proto_plus: True

I’ve tested both version 16 of the API and the latest version, but neither worked.

Were there any changes to the Google Ads API or OAuth processes over the past six months that might be causing this? 
I’d appreciate any guidance on how to solve this. 
Thank you,
Alex 

Alex Papageorgiou

unread,
Nov 21, 2024, 10:20:34 AM11/21/24
to Google Ads API and AdWords API Forum
In case this is useful to anyone, here comes the answer:  
The reason is that the refresh token expires if inactive for 6 months  - which has been the case in what I described above.  

Google Ads API Forum Advisor

unread,
Nov 21, 2024, 12:10:57 PM11/21/24
to alp...@gmail.com, adwor...@googlegroups.com
Hi,

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

From the logs provided, I could see that you have encountered the "invalid_grant" error. The invalid_grant error usually indicates an issue with the refresh token. That said, you’ll need to regenerate credentials and refresh tokens. Alternatively, you may use the OAuth Playground to generate refresh and access tokens. Once you have a valid refresh token, the error should disappear. Furthermore, you may check this document to read more information about refresh token expiration. If the issue persists, please provide us with the complete request and response logs with request ID and request header generated on your end without redacting your data.

If you are using a client library and haven't enabled the logging yet, I would request you to enable logging for the specific client library that you are using. You can refer to the guides Java, .Net, PHP, Python, Ruby or Perl to enable logging at your end. For REST interface requests, you can enable logging via the curl command by using the -i flag.

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

This message is in relation to case "ref:!00D1U01174p.!5004Q02vGlVI:ref" (ADR-00276382)

Thanks,
 
Google Logo Google Ads API Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5



Reply all
Reply to author
Forward
0 new messages