Using dynamic customerId

32 views
Skip to first unread message

Stephen Barrett

unread,
May 11, 2018, 7:04:34 PM5/11/18
to AdWords API and Google Ads API Forum
I've successfully been able to get client's customer ID number during authentication. What is the best procedure on how to use that Client CustomerId instead of the customerId in the ini file?

Dannison Yao (AdWords API Team)

unread,
May 14, 2018, 1:47:03 AM5/14/18
to AdWords API and Google Ads API Forum
Hi Stephen,

You can refer to this guide for code samples on how to help you with your concern. It is highly recommended that you use an adsapi_php.ini file. However, if you don't want to or can't use one, you can refer to this guide on how to do this in PHP.

Regards,
Dannison
AdWords API Team

Peter Bowen

unread,
May 14, 2018, 4:38:02 AM5/14/18
to AdWords API and Google Ads API Forum
Hi Stephen.

In PHP you can pass the client customer id in using the withClientId() method in OAuth2TokenBuilder.php

You can also pass in the OAuth2 refresh token in a similar if you're making the call using the client's credentials rather than your manager account's credentials.

I'm guessing there is a similar way to do it if you're using one of the other libraries.

Stephen Barrett

unread,
May 14, 2018, 11:38:13 AM5/14/18
to AdWords API and Google Ads API Forum
I'm using the method that Sean Bayer created in using client's customer ID when authenticating. 
https://gist.github.com/shawnbayer/87186ec3cc73d3b7788433b5b02bc814

(I'm a newb) I'm assuming I would need to create an instance within the file I'm using to create a new OAuth2TeokenBuiler using this new file I have created and then have 
"->withClientId( $variable ) in the same instance. 

Peter Bowen

unread,
May 14, 2018, 2:07:29 PM5/14/18
to AdWords API and Google Ads API Forum
Hi Stephen.

Without seeing your code I can't comment, but, the code in the gist has already instantiated the Oauth2TokenBuilder so you wouldn't need to do that again.

I've written a high-level article about using multiple oauth tokens here: https://pete-bowen.com/adwords-api-authorize-multiple-users
Reply all
Reply to author
Forward
0 new messages