Continuous Invalid Grant for Google Ads API Token

64 views
Skip to first unread message

Hadil Charafeddine

unread,
Apr 8, 2022, 9:43:00 AM4/8/22
to Google Ads API and AdWords API Forum
Hello team,

Every couple of days, our scripts that make calls to the Google Ads API stop working because we're not able to obtain an access token. The request of getting an access token always comes back with the error: Invalid Grant - Bad Request.

We've been facing the same issue for some time now and we tried every relevant solution we can find online but nothing seems to be a permanent solution.

We're using the authorization flow as mentioned in the documentation of Google Ads API (https://github.com/googleads/google-ads-python/blob/HEAD/examples/authentication/authenticate_in_web_application.py), obtaining the refresh token and then adding the refresh token along with our client id and secret to a json file. Then, we use the credentials json as follows in our python code to make API calls to Google Ads:

googleads_client = GoogleAdsClient.load_from_storage('google-ads-credentials.json', version='v9') # our code breaks here
ga_service = googleads_client.get_service('GoogleAdsService')
[...]
response = ga_service.search(customer_id=str(customer_id), query=query)

Also, we made sure that our Publishing Status is set to production mode in our 'OAuth Consent Screen' section of our Google Cloud Project.

Can you please advise on how we can keep the refresh token working so that our scripts can proceed with making API calls without any interruptions?

Google Ads API Forum Advisor

unread,
Apr 8, 2022, 3:11:48 PM4/8/22
to hadil.cha...@mmpww.com, adwor...@googlegroups.com

Hello Hadil,

Thanks for reaching out to the Google Ads API support. Please note that the API team can address API related issues and concerns. Unfortunately, the existing code changing it’s not on our end to asset you. I would recommend reaching out to their PHP Client Library owner on using this  PHP issue tracker.

Best regards,

Google Logo
Jakeia Sabrina
Google Ads API Team
 

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