I am trying to list all managed accounts under an MCC, but I am getting a 
non-descript "CUSTOMER_NOT_ACTIVE" error. Here is the error:
googleads.errors.GoogleAdsServerFault: 
[AuthorizationError.CUSTOMER_NOT_ACTIVE @ ; trigger:'<null>']

I have seen several threads on here saying that 
ManagedCustomerService.get() should only return active accounts. Here are a 
couple examples of those threads:
https://groups.google.com/forum/#!searchin/adwords-api/customer_not_active$20managedcustomerservice%7Csort:date/adwords-api/euIs6Uhyxn0/wDEMNiLDBQAJ
https://groups.google.com/forum/#!searchin/adwords-api/customer_not_active$20managedcustomerservice%7Csort:date/adwords-api/Ua4aYCNq5SM/r_Ys7RoIAQAJ

I have an active MCC under the authorized user account that has many active 
accounts.

Please advise.

Here is my python code, which uses googleads-python-lib (
https://github.com/googleads/googleads-python-lib 
<https://github.com/googleapis/google-api-python-client>):

API_VERSION = 'v201809'
MANAGED_CUSTOMER_SERVICE = 'ManagedCustomerService'
PAGE_SIZE = 100

def get_managed_accounts(account_id):
oauth2_client = oauth2.GoogleRefreshTokenClient(
g.credentials['client_id'], g.credentials['client_secret'], g.credentials['
refresh_token'])

adwords_client = adwords.AdWordsClient(
os.environ['GOOGLE_ADS_DEVELOPER_TOKEN'],
oauth2_client,
os.environ['GOOGLE_ADS_USER_AGENT'])

managed_customer_service = adwords_client.GetService(
MANAGED_CUSTOMER_SERVICE, version=API_VERSION)

offset = 0
selector = {
'fields': ['CustomerId', 'Name','CanManageClients'],
'paging': {
'startIndex': str(offset),
'numberResults': str(PAGE_SIZE)
},
'predicates':[{
'field': 'ExcludeHiddenAccounts',
'operator': 'EQUALS',
'values': ['true']
}]
}

response = {
'accounts':[]
}

more_pages = True
while more_pages:
# THE ERROR OCCURS WHEN THE FOLLOWING LINE IS EXECUTED
page = managed_customer_service.get(selector)
if 'entries' in page:
accounts = page['entries']
for account in accounts:
print(account)
if account['customerId'] == int(account_id):
continue
else:
response['accounts'].append({
'id': account['customerId'],
'name': account['name'],
'canManageClients': account['canManageClients']
})

offset += PAGE_SIZE
selector['paging']['startIndex'] = str(offset)
more_pages = offset < int(page['totalNumEntries'])

return jsonify(**response)

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/7d0b5399-760d-41f5-9a14-3a76e3b4db97%40googlegroups.com.

Reply via email to