Google API - 401 Error unauthorized_client

471 views
Skip to first unread message

Lee Buckman

unread,
Oct 9, 2024, 9:57:12 AM10/9/24
to Google Ads API and AdWords API Forum
Hello group members,

I wonder if anyone can give me any pointers as to where to look to try and resolve my error.
I have read and followed the instructions/documentation and still seem to be having issues.

  • We have a Google Ads Account which I can access using my own work google account and I have admin access level on the google ads account. 
  • The Google ads account has API Center/API Access and a developer token exists.
  • In GCP console, we have a Client ID/Secret set up and an Oauth app registered allowing access from my work email domain and access to the scope  https://www.googleapis.com/auth/adwords
  • Using the Google Oauth2 playground I authorize using my work google account to give access to the https://www.googleapis.com/auth/adwords scope and get back 1 200 response and the 1 hour token and the refresh token.
  • When using the refresh token and calling https://www.googleapis.com/oauth2/v3/token with my client ID/secret and the refresh token, to try and get a new access token I get the following error.
{
    "error": "unauthorized_client",
    "error_description": "Unauthorized"
}

I have tried multiple things including
  • Generating a new client Secret
  • Generating a whole new Client ID and Secret
  • Re-authorizing to get new access/refresh tokens
  • Using postman to make the call to get the new token from the refresh token
  • Using CURL.
Any help/direction welcomed.

Lee


Google Ads API Forum Advisor

unread,
Oct 9, 2024, 2:04:50 PM10/9/24
to adwor...@googlegroups.com
Hi Lee,

Thank you for reaching out to the Google Ads API support team.

The unauthorized_client error which occurs when there's an issue with your authorization process. Having said that, can you confirm if you have followed this OAuth Desktop and Web Application Flows (“depends on your client library”)guide? Also, could you confirm whether you are using the same client when authorizing in the application and when updating the token on the server? I recommend double checking the client credentials. In order to get provided streams from the Google Ads API you have to use this scope  "https://www.googleapis.com/auth/adwords" and it should be authorized for the Google Ads API. I would recommend you to check the documentation on OAuth 2.0 scopes for more information.

However, If your issue still remains the same, please get back to us with the complete updated API logs (request and response logs with request-id and request header) generated at your end.

I would request you to enable logging for the specific client library that you are using. You can refer to the guides Java, .Net, PHP, Python, Ruby or Perl to enable logging at your end. For REST interface requests, you can enable logging via the curl command by using the -i flag.

You can send the details via Reply privately to the author option, or direct private reply to this email.
 
This message is in relation to case "ref:!00D1U01174p.!5004Q02vGd1K:ref" (ADR-00271136)

Thanks,
 
Google Logo Google Ads API Team


Lee Buckman

unread,
Oct 10, 2024, 2:08:56 AM10/10/24
to ads...@forumsupport.google, adwor...@googlegroups.com
Hello. Ok. I think I have sorted this now. Thanks for the support 

Regards Lee 


From: 'Google Ads API Forum Advisor' via Google Ads API and AdWords API Forum <adwor...@googlegroups.com>
Sent: Wednesday, October 9, 2024 7:04:14 PM
To: adwor...@googlegroups.com <adwor...@googlegroups.com>
Subject: Re: [EXT] google api - 401 error unauthorized_client
 
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwor...@googlegroups.com
To unsubscribe from this group, send email to
adwords-api...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups "Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/5Jvo9000000000000000000000000000000000000000000000SL3OV100yUw80t4BQAC34wr8dOtHZg%40sfdc.net.
The opinions expressed in this e-mail are those of the individual and not necessarily the company. This e-mail and attachment[s] are confidential to the sender and are solely for use by the intended recipient.

Saga Services Limited: Company Registration No. 732602
Saga Publishing Limited: Company Registration No. 2152564
The above companies are wholly owned subsidiaries of Saga Group Limited.

Saga Holidays is a trading name of ST&H Ltd: Company Registration No. 2174052
Saga Personal Finance is a registered trading name of Saga Personal Finance Limited: Company Registration No. 3023493

Saga Group Limited: Company Registration No. 638891
All companies registered at: 3 Pancras Square, London, N1C 4AG

Saga Services Limited is authorised and regulated by the Financial Conduct Authority. Firm Registration Number: 311557
Saga Personal Financial Services Limited is authorised and regulated by the Financial Conduct Authority. Firm Registration Number: 178922
ST&H Ltd is an appointed representative of Saga Services Limited which is authorised and regulated by the Financial Conduct Authority. Firm Registration Number: 455489
Acromas Insurance Company Limited is authorised by the Financial Services Commission, Gibraltar. (FCA Firm Registration Number: 228704)

This e-mail and attachment[s] has been scanned for the presence of computer viruses. Saga accept no responsibility for computer viruses once this e-mail has been transmitted.

Please consider the environment before printing this email.
Reply all
Reply to author
Forward
0 new messages