Access campaign service of Adwords for multiple user

50 views
Skip to first unread message

tarun...@daffodilsw.com

unread,
May 31, 2018, 6:43:37 AM5/31/18
to AdWords API and Google Ads API Forum

I had created an app in google, using client id and secret key I authenticate the user's Adwords account or I get the permission of AdWords.

Now I want to access the campaign service of the same authenticated user. 

As per documents of Adwords service I need developer token and Adwords account id.

 

Kindly let me know the answer to these question :

 

Is there any way to access all authenticated user campaign service without developer token ?. 

 

If developer token is required then for all authenticated user I need their separate developer token.

 

Is there any way to get Adwords account Id and developer token through API.

tarun...@daffodilsw.com

unread,
May 31, 2018, 6:43:37 AM5/31/18
to AdWords API and Google Ads API Forum

I had created an app in google, using client id and secret key I authenticate the user's Adwords account or I get the permission of AdWords in JS.

Dhanya Sundararaju (AdWords API Team)

unread,
May 31, 2018, 11:26:32 AM5/31/18
to AdWords API and Google Ads API Forum
Hi Tarun,

To access campaigns or make any API calls, you will need an approved developer token(to make calls against production accounts) and read-write access to the user's account along with OAuth credentials. Please refer this guide for better clarity. Once your API setup is done, you can get the list of all accounts for which you have access to, via CustomerService.getCustomers() and if you are looking for all accounts under a particular MCC, you can get them via ManagedCustomer.get(). However, developer tokens cannot be pulled up via API. Please let me know if you have any further questions.

Regards,
Dhanya, AdWords API Team

tarun...@daffodilsw.com

unread,
Jun 5, 2018, 7:54:23 AM6/5/18
to AdWords API and Google Ads API Forum
Hi Dhanya,

Thanks for your reply.

Actually, I want to show AdWords Campaign of multiple users. So, for all account, I need separate developer token of there account and Client customer ID?

Is there any way from OAuth credentials to get Campaign data of users?

Thanks,
Tarun

Dhanya Sundararaju (AdWords API Team)

unread,
Jun 5, 2018, 1:33:46 PM6/5/18
to AdWords API and Google Ads API Forum
Hi Tarun,

As a first step, you would need OAuth access to all of the accounts to which you intend to make API calls. After that, using one approved developer token (only one is required and it can be any), you can do a CustomerService.getCustomers without specifying a client customer id. This will get you the list of all those accounts to which you have OAuth access. Then, for each client customer id that was retrieved, you can call the CampaignService.get to get the campaign details or create a Campaign Performance Report to pull up required fields of the Campaign. For example, this java code could be tweaked to pull accounts via CustomerService instead of ManagedCustomerService and then the Campaign Performance Report can be run against each account. For other client libraries, please refer here. Also, please do check out this section of the guide for better clarity on authenticating multiple accounts.

Yes, you can create AdWords Sessions using OAuth credentials as shown in this code sample.

tarun...@daffodilsw.com

unread,
Jun 7, 2018, 8:13:50 AM6/7/18
to AdWords API and Google Ads API Forum

Hi Dhanya,

Through CustomerService.getCustomers I get the list of account. But if I have access to another account (by adding admin access to that user) that account is not getting in this CustomerService.getCustomers service. How I get that account's ?.

Milind Sankeshware (AdWords API Team)

unread,
Jun 7, 2018, 3:44:18 PM6/7/18
to AdWords API and Google Ads API Forum
Hi Tarun,

I am Dhanya's colleague and will be following up on this thread as she is unavailable today. The CustomerService.getCustomers will return the customerIds of the accounts which are directly accessible by the authenticating user. You can check for the canManageClients attribute to confirm if the returned account is manager or a client account. If you are trying to get the client accounts a manager hierarchy that you have access to, you will need to make a separate call to ManagedCustomerService.get(). For more information please check this blog post. Let me know if you have further questions.

Thanks,
Milind, AdWords API Team.

tarun...@daffodilsw.com

unread,
Jun 8, 2018, 1:08:02 AM6/8/18
to AdWords API and Google Ads API Forum
Hi Milind,

Actually, I am facing a problem with another scenario. Suppose I have 2 accounts of AdWords a...@gmail.com and x...@gmail.com

In a...@gmail.com I have one l1 manager account and I provide the access of l1 account to x...@gmail.com as admin.

In x...@gmail.com account I have l2 manager account and also have access to the l1 account.

So, when I access the x...@gmail.com through CustomerService.getCustomers service I get the only l2 account(I am not getting the l1 account.). And through ManagedCustomerService.get()  I get the hierarchy of l2. 

So, how I get the l1 account in x...@gmail.com as I have access to same?

Milind Sankeshware (AdWords API Team)

unread,
Jun 8, 2018, 3:19:09 PM6/8/18
to AdWords API and Google Ads API Forum
Hi Tarun,

Please find my response below:
  1. The  CustomerService.getCustomers() will only return users who are directly accessible by the user authenticating the API call. So if you're logged in with xyz@gmail, it will only have once direct member which is L2. If you're logged in with a...@gmail.com and authenticating the API call, this will return the users who are directly accessible from this account. 
  2. You can then perform a ManagerCustomerService.get() for the Manager account from results of step 1. This will return all accounts under that Manager account.
Let me know if you have any further questions.

tarun...@daffodilsw.com

unread,
Jun 12, 2018, 6:52:04 AM6/12/18
to AdWords API and Google Ads API Forum
  • One more issue, Suppose I have an AdWords (q...@gmail.com) account in which I have created 2 accounts. One is production account (i.e p1) and second is test account. (i.e t1) both are manager account. When I used CustomerService.getCustomers service I got an error of developer token not approved. But if an account with the only test account I successfully get its ID in  CustomerService.getCustomers service. So is this an issue or what is that I didn't get this because if we use CustomerService.getCustomers  service it supposes to return at least t1 account which is a test account. Or I have applied for the basic level token or Approved developer token?. 

Milind Sankeshware (AdWords API Team)

unread,
Jun 12, 2018, 2:48:42 PM6/12/18
to AdWords API and Google Ads API Forum
Hi Tarun,

Please find my response below:
  1. As per your description in the earlier email, x...@gmail.com is a user on both l1 and l2 accounts. Hence, if you use the credentials of x...@gmail.com and perform a CustomerService.getCustomers without the client customer id in the header, the API should return both these accounts. If the x...@gmail.com is not a user on the l1, you can add this email id as a user by referring to this guide
  2. Please note that with unapproved developer token you can only make a call against the test account. The getCustomers method will return only test accounts if the developer token used has not been approved. 
Let me know if you have further questions.
Reply all
Reply to author
Forward
0 new messages