using service account auth flow from php library

161 views
Skip to first unread message

Nayana Hettiarachchi

unread,
Sep 20, 2023, 4:29:29 AM9/20/23
to Google Ads API and AdWords API Forum
Hi,

I have logged into google cloud console and search for the ads api and then click manage and created a service account. I didn't give it any permissions because I wasn't able to find any permissions related to ads api. then once the service account was successfully created I went ahead and created a key and then use the key for the service account auth flow in  the PHP library. I tried executing basic example GetCampaigns.php and I get the following error.

php GetCampaigns.php
PHP Fatal error:  Uncaught GuzzleHttp\Exception\ClientException: Client error: `POST https://oauth2.googleapis.com/token` resulted in a `401 Unauthorized` response:
{
  "error": "unauthorized_client",
  "error_description": "Client is unauthorized to retrieve access tokens using this method, or client not authorized for any of the scopes requested."
}

am I missing some sort of permission for the service account I created? Please let me know.

Best Regards
Nayana

Google Ads API Forum Advisor

unread,
Sep 20, 2023, 10:39:07 AM9/20/23
to nay...@gmail.com, adwor...@googlegroups.com
Hi,

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

By reviewing your query, I understand that you are getting the error message "unauthorized_client" when you are trying to execute the GetCampaigns.php. I would recommend you to please refer to these steps on how to Generate tokens for more information.

If you are still facing this issue related to the access token, I would recommend you to reach out to the GCP Product support team for further assistance. Kindly note that we can assist you only with the technical queries related to the Google Ads API.

Please reach out to us if you have any queries related to the Google Ads API.

 
This message is in relation to case "ref:_00D1U1174p._5004Q2ozjGi:ref"

Thanks,
 
Google Logo Google Ads API Team


Reply all
Reply to author
Forward
0 new messages