I am building an Adwords application with oAuth 2.0 authentication in python.
I'm able to retrieve all Adwords accounts associated with a google account using the get_accounts function below. But now I would like to drill down deeper into the account hierarchy if an account canManageClients (read: mcc account).
How to retrieve Adwords accounts under an MCC account using CustomerService?
How I am currently retrieving accounts:
from googleads import adwords
def get_accounts(client):
customer_service = client.GetService('CustomerService', version='v201806')
selector = {
'fields': ['customerId', 'descriptiveName', 'canManageClients']
}
accounts = customer_service.getCustomers(selector)
result = []
for account in accounts:
customerId = account['customerId']
name = account['descriptiveName']
canManageClients = account['canManageClients']
if canManageClients:
# How to retrieve all accounts under MCC account here?
result.append({"id": customerId, "name": name, "canManageClients": canManageClients})
return result