I've set up the whole Google Ads API according to this manual here: https://developers.google.com/google-ads/api/docs/client-libs/python/oauth-desktop?hl=en
I got my refresh token and put it in my google-ads.yaml file which looks exactly like this: https://github.com/googleads/google-ads-python/blob/master/google-ads.yaml. I also put my client_id, developer_token and client_secret at the corresponding spots in the file.
Everything worked out and I tried an example to get forecast metrics of few keywords campaigns: https://developers.google.com/google-ads/api/docs/keyword-planning/generate-forecast-metrics. Also I could use other services of the API.
Each time I use the API I access it via the client using the following code:
from google.ads.google_ads.client import GoogleAdsClientAs I already said it worked.
A few days later I tried to connect again and I got the following error:
google.auth.exceptions.RefreshError: ('invalid_grant: Bad Request', {'error': 'invalid_grant', 'error_description': 'Bad Request'})
So I did the process of getting a new refresh token again (https://developers.google.com/google-ads/api/docs/client-libs/python/oauth-desktop?hl=en) such that everything worked out again.
One day later I got the same error again. Please someone suggest me the reason for this error.
Hi Karthik,
Thanks for reaching out to us. Kindly note that the invalid_grant usually indicates an issue with the refresh token. That said, you’ll need to regenerate credentials and refresh tokens. You may refer here to this guide for the steps on how you can regenerate credentials and refresh tokens.
Should you continue to encounter issues with the said token, even after following the steps from the above guide, I would recommend that you reach out instead to the Google API Console Support team via this link.
Regards,
|
||||||