Invalid access tokens

2,248 views
Skip to first unread message

Bo Andersen

unread,
Mar 15, 2017, 8:16:26 AM3/15/17
to AdWords API Forum
Hello,

I am trying to debug why my access tokens are invalid. When using them with the API, I get the following error: AuthenticationError.OAUTH_TOKEN_INVALID

I did some research, but I couldn't find a reason why that would be the case (I don't think the common issues are applicable in this case). I am also sending along a refresh token with my requests. I cannot seem to figure out a pattern as to when the tokens yield this error. For instance, I tried to get a completely fresh access + refresh token, and use it immediately for a request, but also got this error.

The application is a web application which uses the oauth2 flow. Since I am trying to debug this in an application that I didn't write myself (nor have I seen the code before now), I still have a bit of debugging to do. But I can verify that the oauth2 flow completes without errors, and that both an access token and refresh token is saved as a result. The problem then occurs whenever I try to use these tokens for API requests using the Google Ads API Client Library for PHP (https://github.com/googleads/googleads-php-lib). Everything used to work, but suddenly things stopped working without any code being changed at all. From what I was told, the problems started occurring sometime in January.

I have tried to take a completely fresh access token to verify it on the below URL.


But I just get the following response.

{ "error_description": "Invalid Value" }

Like I said, I have to dive a bit deeper in my debugging, but does anyone have any pointers as to what could possibly cause this? Anything that could give me a clue would be helpful.

Thanks a lot in advance.

Vishal Vinayak (Adwords API Team)

unread,
Mar 15, 2017, 3:35:44 PM3/15/17
to AdWords API Forum
Hi,

In general, you may see OAUTH_TOKEN_INVALID error if the access token in your request header is not valid. Access tokens have a limited time validity and they expire in 1 hour (3600 seconds). Our client libraries handle the mechanism of generating a new access token from your refresh token when an access token expires. Refresh tokens, on the other hand, do not expire and are meant to be kept safely in your local environment (should not be sent with your API call). Could you please download a fresh copy of the PHP client library, configure your OAuth credentials and check if you are able to get campaign information for your account when you run this example?

Regards,
Vishal, AdWords API Team
Reply all
Reply to author
Forward
0 new messages