How to get client customer id of authorized adword account user through oauth2 in PHP

277 views
Skip to first unread message

Pratik Patel

unread,
May 27, 2020, 7:51:44 AM5/27/20
to AdWords API and Google Ads API Forum

Hi,


I am developing app where user authorize to app using their adword account credential and later they can see their ad campaigns and all. 
I am trying to call CustomerService.getCustomers without ClientCustomerId in header.
getting AuthenticationError.CLIENT_CUSTOMER_ID_IS_REQUIRED 

is there any other service available to get client customer id ?

Pratik Patel

unread,
May 27, 2020, 8:05:39 AM5/27/20
to AdWords API and Google Ads API Forum
as per documentation "Client Customer Id is required if CustomerIdMode is set to CLIENT_EXTERNAL_CUSTOMER_ID. Starting version V201409 ClientCustomerId will be required for all requests except for CustomerService.get"
can you please help me how to change CustomerIdMode?
 

Google Ads API Forum Advisor Prod

unread,
May 27, 2020, 2:39:21 PM5/27/20
to p...@conversio.dk, adwor...@googlegroups.com

Hi Pratik,

Thank you for reaching out. The documentation you quoted was a prior version and was deprecated. The current version does not have the get() instead it is getCustomer() which requires you to provide the client customer id to make the API calls. 

Thanks and regards,
Xiaoming, Google Ads API Team



 

ref:_00D1U1174p._5004Q1zsDUN:ref

Pratik Patel

unread,
May 28, 2020, 12:37:51 AM5/28/20
to AdWords API and Google Ads API Forum
But there has to be a way where i can get client customer id from user authorized through my app, i have seen in few applications where external user can authorized using their adword account credential and see list of their accounts from adword api, how is it possible then? please provide me proper guide.
Regards. 

Google Ads API Forum Advisor Prod

unread,
May 28, 2020, 3:06:28 PM5/28/20
to p...@conversio.dk, adwor...@googlegroups.com

Hi Pratik,

Thank you for reaching out. If you need to get the client customer id from users that are authorized through your app you would need to use getCustomer() and set your manager account id as the client customer id, then you would be able to get all the direct customer accounts under your manager account.



Thanks and regards,
Xiaoming, Google Ads API Team



 

ref:_00D1U1174p._5004Q1zsDUN:ref

Pratik Patel

unread,
May 29, 2020, 1:17:17 AM5/29/20
to AdWords API and Google Ads API Forum
Hi,

I am getting error AuthorizationError.USER_PERMISSION_DENIED  , Adword Account User authorized to my app are not linked to my ad manager account.

Main purpose of our app is to get data of adword account of clients who are not connected to our ad manager account, thats why we use oauth based authentication and not service account.

Regards,
Pratik.

Google Ads API Forum Advisor Prod

unread,
May 29, 2020, 2:27:27 PM5/29/20
to p...@conversio.dk, adwor...@googlegroups.com

Hi Pratik,

Thank you for reaching out. The error USER_PERMISSION_DENIED usually occurs when there is no link between the manager account authenticated in the request and the client account specified in the headers. This type of issue is not due to the authentication itself. Rather, it is because the account you are authenticated with does not have the management rights to the client customer account as they are not linked. You would need to make sure they are linked in order to successfully make the API call.



Thanks and regards,
Xiaoming, Google Ads API Team



 

ref:_00D1U1174p._5004Q1zsDUN:ref

Pratik Patel

unread,
Jun 2, 2020, 6:04:43 AM6/2/20
to AdWords API and Google Ads API Forum
Hi,

Is there any way to get authenticated user's client customer id without any prior management rights to my ad manager account ?
Also let me know if this is possible for other languages client library other than PHP.

It is important for our app to allow external user to connect to our app and view information from their adword account.
I have also noticed in other web applications provides such kind of facilities to their users.

Regards,
Pratik

Google Ads API Forum Advisor Prod

unread,
Jun 2, 2020, 3:30:44 PM6/2/20
to p...@conversio.dk, adwor...@googlegroups.com
Hi Pratik,

Thank you for the update. I'm taking a look over this case on Xiaoming's behalf. I took a look over the issue and see that you're experiencing a USER_PERMISSION_DENIED error while trying to get a list of customer IDs from your clients. This is able to be done via Web App Flow which I currently see that you're using. Please note that this is also available in other client library languages. Can you please confirm if you have the latest client library and have completed the set up for Web App Flow?

Thank you,
Bryan, Google Ads API Team

ref:_00D1U1174p._5004Q1zsDUN:ref

Pratik Patel

unread,
Jun 3, 2020, 1:00:02 AM6/3/20
to AdWords API and Google Ads API Forum
Hi,

I am using "googleads/googleads-php-lib": "^47.0" , i have implemented webflow (https://github.com/googleads/googleads-php-lib/wiki/API-access-on-behalf-of-your-clients-(web-flow)).
My aim is to get client customer id of authorized adword account .

Regards,
Pratik

Google Ads API Forum Advisor Prod

unread,
Jun 3, 2020, 3:11:09 PM6/3/20
to p...@conversio.dk, adwor...@googlegroups.com
Hi Pratik,

I see that you've been encountering some errors while running the getCustomers request. Could you provide me with your request and response logs where you get this error so that I may further investigate? For privacy, you can click "reply privately to the author".

Pratik Patel

unread,
Jun 4, 2020, 2:50:40 AM6/4/20
to AdWords API and Google Ads API Forum
My problem is when client first time register to my app, obviously his google ad account is not linked to my ad manager account, then how can i get his clientCustomerId  ?
manually i can't ask his customer id. I have seen in other apps, where they connect to new client from their app by clicking on just google ad login button.
Please help me to resolve this problem.

Regards,
Pratik.

Google Ads API Forum Advisor Prod

unread,
Jun 4, 2020, 12:53:24 PM6/4/20
to p...@conversio.dk, adwor...@googlegroups.com
Hi Pratik,

Thank you for your patience. I'll take a look at this internally with my team and get back to you as soon as possible.

Pratik Patel

unread,
Jun 15, 2020, 12:22:10 AM6/15/20
to AdWords API and Google Ads API Forum
Hi,

Can you please tell me how much time it would take to get response from Google ads team?

 Regards,
 Pratik.

Pratik Patel

unread,
Jun 18, 2020, 1:40:39 AM6/18/20
to AdWords API and Google Ads API Forum
Any updates? 

Google Ads API Forum Advisor Prod

unread,
Jun 19, 2020, 4:05:21 PM6/19/20
to p...@conversio.dk, adwor...@googlegroups.com
Hi Pratik,

Apologies for my delayed response. You should not need to provide a Customer ID when using the CustomerService.getCustomers method. Since you received the error CLIENT_CUSTOMER_ID_IS_REQUIRED I'm inclined to think this is a bug in our system. I'm going to file an issue with our engineering team and will keep you updated on their progress.

Again - I'm sorry about the extended back-and-forth and my delayed response. We should have recognized this bug sooner. I'll do my best to try to get this resolved as quickly as possible.

Best,
Ben, Google Ads API Team

ref:_00D1U1174p._5004Q1zsDUN:ref

Tarannum

unread,
Sep 7, 2020, 9:38:17 AM9/7/20
to AdWords API and Google Ads API Forum
can any of you can update on this?
Pratik do you find some way to achieve this. Please help us I am also struck in same case.

Google Ads API Forum Advisor Prod

unread,
Sep 8, 2020, 9:20:21 AM9/8/20
to ansitta...@gmail.com, adwor...@googlegroups.com
Hi All,

While Pratik investigates, it might be worth looking at previous Issues filed against the PHP library to see if other users have encountered this issue already.

If not, filing an Issue there might help you get the issue resolved more quickly because the users there have much more experience with the library. This support forum is intended to help with more general API issues, but his problem seems related to the PHP library, specifically.
Reply all
Reply to author
Forward
0 new messages