Unauthorized_client error

62 views
Skip to first unread message

Stephen Barrett

unread,
May 7, 2018, 3:56:25 PM5/7/18
to AdWords API and Google Ads API Forum

I am getting this erro: Uncaught GuzzleHttp\Exception\ClientException: Client error: `POST https://www.googleapis.com/oauth2/v4/token` resulted in a `401 Unauthorized` response. I have checked clientID, ClientSecret, and RefreshToken and they are all correct. 


I'm wondering if this has to do with the user flow I'm trying to create. What is the best web flow for a client to access their data through a manager? Would I have to set up a service account? I'm doing this all through my terminal first before moving it to my website. 

Vincent Racaza (AdWords API Team)

unread,
May 7, 2018, 11:27:30 PM5/7/18
to AdWords API and Google Ads API Forum
Hi Stephen,

The "401 Unauthorized" error means that the email address that you used in generating the OAuth2 credentials is not a valid user in your account, 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). Also, the recommended authentication type for AdWords API is the "Installed application" type. See this guide to know more on how to authenticate using this type. You don't need to authenticate as a service account as you only authenticate via this type if you have a G Suite domains and your main goal is to impersonate as any user in your account.

Please try authenticating via the "Installed application" type again and let me know how it works. If you encounter any error, please provide the complete error logs as well as your clientCustomerId and the email address you used in the generation of your OAuth2 credentials via Reply privately to author option.

Thanks,
Vincent
AdWords API Team
Reply all
Reply to author
Forward
0 new messages