[AuthenticationError.OAUTH_TOKEN_INVALID @ ; trigger:'<null>']

48 views
Skip to first unread message

wei Cai

unread,
Dec 2, 2019, 8:09:41 AM12/2/19
to AdWords API and Google Ads API Forum
I'm getting an OAUTH_TOKEN_INVALID about halfway into a job.I installed the AdWords API client library for Python and get an OAuth2 refresh token with your API guides. my yaml file likes the picture.
1575291267(1).png
1575291316(1).png
1575291402(1).png
1575291715(1).png

Google Ads API Forum Advisor Prod

unread,
Dec 2, 2019, 3:51:16 PM12/2/19
to joyp...@gmail.com, adwor...@googlegroups.com
Hi Wei,

The AuthenticationError.OAUTH_TOKEN_INVALID error that you encountered occurs when the access token passed with the HTTP header was not correct. To verify that your credentials are correct, could you try the CURL request provided below and see if you are able to generate the access tokens? If the credentials are correct, you should get an access token for the below request.

curl https://www.googleapis.com/oauth2/v4/token \
-d refresh_token=your-refresh_token \
-d client_id=your-client-id \
-d client_secret=your-client-secret \
-d grant_type=refresh_token

If your credentials are incorrect and still facing an issues, could you generate a new refresh token with the help of this guide and retry your request?

Thanks,
Bharani, Google Ads API Team

ref:_00D1U1174p._5001UODbOt:ref

wei Cai

unread,
Dec 2, 2019, 10:34:32 PM12/2/19
to AdWords API and Google Ads API Forum
Hi Bharani:


在 2019年12月3日星期二 UTC+8上午4:51:16,adsapiforumadvisor写道:
Hi Wei,
     I can get the access tokens with the CURL request you provided.but I don`t known where  should I write the acess token i got. And What should I fill in this field u"ser_agent"

Google Ads API Forum Advisor Prod

unread,
Dec 3, 2019, 2:00:24 PM12/3/19
to joyp...@gmail.com, adwor...@googlegroups.com
Hi Wei,

The CURL request is only to verify if your credentials are correct. Since you’re not receiving any error, it looks like the credentials are all correct. Based on your error logs, could you ensure that the properties file is being read correctly. Can you check whether you are adding the correct location to the .yaml in your code snippet? 

The field “User Agent”, it is an optional header that defines the sender and purpose of the request. For more information on userAgent, please see here.

wei Cai

unread,
Dec 8, 2019, 10:23:21 PM12/8/19
to AdWords API and Google Ads API Forum

Hi Bharani,

1575861703(1).png

   I'm sure that the location of the .yaml file is correct. It's correct for me to replace the information in the file with our old account, but the current account will prompt "OAuth [token] invalid". Then I changed my writing method. I didn't read the yaml file, and the information in the code file will be replaced with our old account, but the current account will prompt "OAuth_token_invalid" I changed my writing method to not read the yaml file. The code is as shown in the figure. If I write the parameters of the old account, it can be used normally, but if I replace the parameters of the new account, it still report the same error as before.
Thanks,
wei

在 2019年12月4日星期三 UTC+8上午3:00:24,adsapiforumadvisor写道:

Google Ads API Forum Advisor Prod

unread,
Dec 9, 2019, 12:11:33 PM12/9/19
to joyp...@gmail.com, adwor...@googlegroups.com
Hi Wei, 

Thank you for the information. Could I ask you to generate the OAuth credentials again for the new account and try generating the refresh token with your corresponding, valid Google Ads Account email? Could you also confirm if you still have access to the project where you’re generating the OAuth credentials in the developer console? It could be one of the reasons that you get the token invalid errors. 

Regards,
Reply all
Reply to author
Forward
0 new messages