3

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 could for example ask for all campaigns: https://developers.google.com/google-ads/api/docs/samples/get-campaigns#python. 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 GoogleAdsClient
client = GoogleAdsClient.load_from_storage(path_to_google_ads_yaml_file)

As I already said it worked.

A few days later I tried to connect again and I got the following error:

 “error”: “invalid_grant”, “error_description”: “Token has been expired or revoked.”

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. So my question is: What is the purpose of the refresh token? I thought it allows me to access the API without ever having to ask for a new token or refresh token!?

Now, I again tried to connect to the API once more (although it didn't work last time) and now I got an even worse and new error:

'invalid_grant: Bad Request', '{\n  "error": "invalid_grant",\n  "error_description": "Bad Request"\n}'

So things are getting even more complicated...

the_economist
  • 487
  • 1
  • 8
  • 20
  • I am getting the same issue, even I have refreshed token but that not working now. It was working file before – KalimR Feb 28 '21 at 09:05
  • 1
    Faced the same issue and answered my own question: https://stackoverflow.com/questions/66240374/token-has-expired-or-revoked-google-ads?noredirect=1#comment117109587_66240374 – fatima Ajij Mar 03 '21 at 22:37

1 Answers1

-1

As @fatima Ajij pointed out, the whole issue / problem lies in the settings: Have a look at his answer: Token has expired or revoked - Google Ads Thanks a lot, fatima Ajij!

the_economist
  • 487
  • 1
  • 8
  • 20
  • An app should not need to be "published" in order for the refresh token to persist. Apps that are in "testing" mode should behave the same as "production" apps (except for the limited number of users). – IanS Apr 22 '21 at 15:38
  • If this solution is true, this is surely a bug that Google need to fix? – IanS Apr 22 '21 at 15:48