How to get Google Ads accounts using API via Oauth2 Authentication.

960 views
Skip to first unread message

Praduman Tiwari

unread,
Oct 3, 2019, 8:30:46 AM10/3/19
to AdWords API and Google Ads API Forum
Hello :),
I'm trying to access all the Google Ads accounts which are linked to my connected account.

I am developing an APP which is based on Ad creation, I have integrated the FB and currently stuck in Google Ads.


Please check my FB flow in my attachment. 

image_2019_10_03T09_47_40_442Z.png




And, I am trying to as it flows for Google Ad. I have already done Oauth2 for an account and get the permission of "Manage your AdWords campaigns".

please suggest the best way to continue my

Screenshot_1.png



Thanks in advance.

Google Ads API Forum Advisor Prod

unread,
Oct 3, 2019, 11:06:26 AM10/3/19
to praduma...@himanshusofttech.com, adwor...@googlegroups.com
Hello Praduman,

If you are using AdWords API, you can use the ManagedcustomerService.get function to fetch all the clients under your manager account. You have to pass the manager customer id as the customerClientId for this specific API call as we are fetching all the clients linked to manager account.

If you are using Google Ads API, please use the below search query to get the client accounts linked to a specific manager account. Even here while making the API call you have to use manager customer id as the customerClient Id for this specific search query. 

Query: "SELECT customer_client.client_customer, customer_client.currency_code, customer_client.descriptive_name, customer_client.hidden, customer_client.id, customer_client.level, customer_client.manager, customer_client.resource_name, customer_client.test_account, customer_client.time_zone  FROM customer_client"

Please let me know if you have any further questions.

Regards,
Sai Teja, Google Ads API Team

ref:_00D1U1174p._5001UKM2Ru:ref

Praduman Tiwari

unread,
Oct 4, 2019, 3:21:33 AM10/4/19
to AdWords API and Google Ads API Forum
Hello, Sai :),

Thanks for the reply.

As you suggest me to Apply "clientCustomerId" of manager a/c to fetch the all clients user in my manager a/c.
Please suggest any way to get clientCustomerId of the manager account which is connected to my APP, 
I am using this code for authentication.

$client = new Google_Client();
$client->setClientId(GOOGLE_CLIENT_ID);
$client->setClientSecret(GOOGLE_CLIENT_SECRET);
$client->setRedirectUri(REDIRECT_URL);
$client->setAccessType("offline");
$client->setApprovalPrompt("force");
$client->addScope("email");
$client->addScope("profile");


I am unable to find the "clientCustomerId" after completing the authentication, 

Google Ads API Forum Advisor Prod

unread,
Oct 4, 2019, 4:28:58 PM10/4/19
to praduma...@himanshusofttech.com, adwor...@googlegroups.com

Hi Praduman,

Thank you for reaching out. Have you gone through the steps to sign up your account and make your first api call? If so, you should be able to get your manager account ID from the Google Ads UI. You can insert this ID where it says “api.adwords.clientCustomerId=” in the “properties” file within the “resources” folder. You can follow this example to get all the accounts under your manager account.

Regards,
Anthony
Google Ads API Team



ref:_00D1U1174p._5001UKM2Ru:ref

Praduman Tiwari

unread,
Oct 5, 2019, 3:27:30 AM10/5/19
to AdWords API and Google Ads API Forum
Hello Sai,
Thanks for the support.
Q. Have you gone through the steps to sign up your account and make your first api call?
Ans. Yes, I have completed this step and complete the rest flow, like as getting campaigns, get Groups and create Ads also, but unable to get the "clientCustomerId" dynamically.

As you mentioned, "you should be able to get your manager account ID from the Google Ads UI.". That's means we need to add "clientCustomerId" manually in my APP to get Ads accounts of the manager account??

I want to get it(clientCustomerId) dynamically.

Google Ads API Forum Advisor Prod

unread,
Oct 7, 2019, 11:28:46 AM10/7/19
to praduma...@himanshusofttech.com, adwor...@googlegroups.com

Hi Praduman,

Yes, the only way to get the clientCustomerId of the manager account is manually through the UI. Once you have that ID, you can retrieve all the clientCustomerId’s of the clients dynamically through the API.



Regards,
Anthony
Google Ads API Team



ref:_00D1U1174p._5001UKM2Ru:ref

Praduman Tiwari

unread,
Oct 8, 2019, 2:32:52 AM10/8/19
to AdWords API and Google Ads API Forum
Hello Anthony,
Thanks for the reply, I really appreciate your reply.

My APP flow is:

1. Connect email with respective credentials (Done)
2. Get all Google Ads account with respective connected email (Pending)
3. Get all campaigns with respective Google Ads account (Done)
4. Get all group of respective campaigns (Done) 

As you can see, I am facing issues in the second step, I have completed the rest one with putting the Static ClientCustomerId.

I am trying to get all Google Ads account list, which is in my connected google account with Oauth2 authentication.

You can see below in my attached screenshot, that site is getting my Ads account after completing the authentication process, without asking any manager id.

Screenshot_1.png

Google Ads API Forum Advisor Prod

unread,
Oct 8, 2019, 11:53:16 AM10/8/19
to praduma...@himanshusofttech.com, adwor...@googlegroups.com

Hi Praduman,

It looks like the CID you provided in the screenshot is for a client account. In order to retrieve all the accounts, you need the CID of your manager account. If you go to the UI, click Account & Settings -> Account access -> Managers to get the desired CID of the account you want to check. Once you put this into your application, you can follow this example to get all the accounts under your manager account.



Regards,
Anthony
Google Ads API Team



ref:_00D1U1174p._5001UKM2Ru:ref

Niti Bala

unread,
Oct 18, 2019, 8:50:05 AM10/18/19
to AdWords API and Google Ads API Forum
Hi Anthony,

I am trying to fetch currency of an ad account but failed. Can you please help me out to get currency.

Thanks in advance

Google Ads API Forum Advisor Prod

unread,
Oct 18, 2019, 11:03:54 AM10/18/19
to ni...@himanshusofttech.com, adwor...@googlegroups.com

Hi Niti,

You can get the currency of the account by selecting the AccountCurrencyCode from the Account Performance Report. See this sheet for the currency code conversions.



Regards,
Anthony
Google Ads API Team



ref:_00D1U1174p._5001UKM2Ru:ref

Tarannum

unread,
Sep 8, 2020, 3:26:40 AM9/8/20
to AdWords API and Google Ads API Forum
Hi all, Please let me know the solution get in order to get ClientCustomerid from Customerid of the Client who access my Goggle  App with Login process.
Please help. Its urgent.

Google Ads API Forum Advisor Prod

unread,
Sep 9, 2020, 11:50:53 AM9/9/20
to ansitta...@gmail.com, adwor...@googlegroups.com
Hello,

You can retrieve the client customer id by selecting the ExternalCustomerId when running reports.


Regards,
Anthony
Google Ads API Team

Google Logo
Anthony
Google Ads API Team
 


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