Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error: `POST https://www.googleapis.com/oauth2/v4/token` resulted in a `401 Unauthorized` response: { "error": "unauthorized_client", "error_description": "Unauthorized" }

723 views
Skip to first unread message

sneha mahale

unread,
Oct 18, 2019, 1:00:17 AM10/18/19
to AdWords API and Google Ads API Forum
Hi,
I got the below error
Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error: `POST https://www.googleapis.com/oauth2/v4/token` resulted in a `401 Unauthorized` response:
{
  "error": "unauthorized_client",
  "error_description": "Unauthorized"
}

but when I try to run this
curl https://www.googleapis.com/oauth2/v4/token \
-d refresh_token=MCC_refresh_token \
-d client_id=your-client-id \
-d client_secret=your-client-secret \
-d grant_type=refresh_token

I runs successfully and gives me the access token.
but when try to download report it gives above error 'unauthorized_client'

Google Ads API Forum Advisor Prod

unread,
Oct 18, 2019, 1:59:25 AM10/18/19
to adwor...@googlegroups.com

Hi Sneha,

Thank you for posting your concern.

The "401 Unauthorized" error means that the email address that you used in generating the OAuth2 credentials is not a valid user in the account you specified as clientCustomerId, or it could be that there is something wrong in the generation of your OAuth2 credentials itself (e.g. your refresh token is not matched with your client ID and secret).

With this, could you try to re-generate the OAuth2 credentials? Please make sure that the user authenticating the API call is having access to the target account. Please check this guide to see the steps to setup OAuth2 authentication. 

If the issue persists, could you provide the email address you used in generating the credentials via Reply privately to author?

Please let me know if you have further concerns.

Regards,
Hiroyuki
Google Ads API Team



ref:_00D1U1174p._5001UKNkRb:ref
Reply all
Reply to author
Forward
0 new messages