"error": "unauthorized_client", "error_description": "Unauthorized"

974 views
Skip to first unread message

Will Ill

unread,
Aug 22, 2022, 2:46:17 PM8/22/22
to Google Ads API and AdWords API Forum
Hello, i'm trying to execute GetCampaigns.php from the google ads api tutorial but i get "error": "unauthorized_client",   "error_description": "Unauthorized".

Google Ads API Forum Advisor

unread,
Aug 22, 2022, 3:09:51 PM8/22/22
to thel...@gmail.com, adwor...@googlegroups.com
Hi Will,

Did you place all your credentials created with OAuth Desktop and Web Application Flows in placeholders in google_ads_php.ini without extra spaces? Is the google_ads_php.ini file in the home directory?

Regards,

Google Logo
Aryeh
Google Ads API Team
 


ref:_00D1U1174p._5004Q2dmQ1K:ref

Google Ads API Forum Advisor

unread,
Aug 22, 2022, 3:20:13 PM8/22/22
to thel...@gmail.com, adwor...@googlegroups.com
Hi Will, 

To debug authentication access issues you while bypassing client library issues you may try generating a refresh tokek ny following our OAuth Playground guide. and add a scope of 'https://www.googleapis.com/auth/userinfo.email' besides the Ads API scope of 'https://www.googleapis.com/auth/adwords' and then you can test who made the refresh token and what scopes this token has by generating an access token using this Bash terminal ready curl recipe for Generating new access tokens, then using the following recipe in a browser:

https://oauth2.googleapis.com/tokeninfo?access_token=<INSERT_ACCESS_TOKEN>;.
 

If that works, then let's try a request from the command line:

  • curl -i --header "Authorization: Bearer <INSERT_ACCESS_TOKEN>" --header "developer-token: <INSERT_DEV_TOKEN>" --header "login-customer-id: {LGNCID}" --data "{ 'query': 'SELECT campaign.id FROM campaign LIMIT 1' }" -X POST -H "Content-Type: application/json" https://googleads.googleapis.com/v11/customers/{CID}/googleAds:searchStream
If the above doesn't work, could you send us the results of all the above?

If it does work, you may use the refresh token generated above with your PHP installation. If it doesn't work there, could you send us a 'DEBUG' log level request and response log of raw API communications ?

The request and response appears similar to the JSON Mappings in our REST documentation with additional headers and information such as request Id. Here are logging instructions for our PHP Ads API Client Library.

You may send the requested information via "Reply to author" or via googleadsa...@google.com with a link to this forum post added to the new thread.
Reply all
Reply to author
Forward
0 new messages