"CUSTOMER_NOT_ACTIVE" error when using ManagedCustomerService.get()

101 views
Skip to first unread message

Ben Foster

unread,
Nov 8, 2019, 2:18:34 PM11/8/19
to AdWords API and Google Ads API Forum

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:

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):

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)

Ben Foster

unread,
Nov 8, 2019, 2:32:49 PM11/8/19
to AdWords API and Google Ads API Forum
To provide more context here, the authorized user account whose credentials I'm using to make the request DOES have direct access to multiple cancelled accounts, but it also has access to an MCC that has many active accounts. Based on my understanding from other support threads and this blog post from last year (https://ads-developers.googleblog.com/2018/03/changes-to-inactive-adwords-accounts.html), the expected behavior would be that all active accounts are returned by this request and cancelled accounts are ignored. Instead, I am getting the error mentioned in my previous post and nothing is returned.

Ben Foster

unread,
Nov 8, 2019, 2:55:10 PM11/8/19
to AdWords API and Google Ads API Forum
I should also note that the following code, which uses CustomerService.getCustomers() and is using the same user's credentials as the previous code, is working fine and only returning active accounts:

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

# Initialize the AdWords client.
adwords_client = adwords.AdWordsClient(
os.environ['GOOGLE_ADS_DEVELOPER_TOKEN'],
oauth2_client,
os.environ['GOOGLE_ADS_USER_AGENT'])

customer_service = adwords_client.GetService(CUSTOMER_SERVICE, version=API_VERSION)

accounts = customer_service.getCustomers()

response = {
"accounts": []
}

for account in accounts:
response['accounts'].append({
'id': account['customerId'],
'name': account['descriptiveName'],
'canManageClients': account['canManageClients']
})

return jsonify(**response)

Ben Foster

unread,
Nov 8, 2019, 3:19:49 PM11/8/19
to AdWords API and Google Ads API Forum
This is resolved... I was not passing the client_customer_id to the get() request. The revised snippet looks like this:

# Initialize the AdWords client.
adwords_client = adwords.AdWordsClient(
os.environ['GOOGLE_ADS_DEVELOPER_TOKEN'],
oauth2_client,
os.environ['GOOGLE_ADS_USER_AGENT'],
client_customer_id=account_id)

Google Ads API Forum Advisor Prod

unread,
Nov 8, 2019, 4:19:39 PM11/8/19
to b...@saltbox.solutions, adwor...@googlegroups.com
Hi Ben, 

I'm glad that the issue specific to CustomerService.getCustomers() has been resolved. Could you please confirm if you still need assistance for the CUSTOMER_NOT_ACTIVE error that you were receiving? If yes, please note that the CUSTOMER_NOT_ACTIVE error is triggered when the customer is no longer active. Could you please check if the account is still active? If you're receiving an error, could you please share the client customer Id used in the request, using the Reply privately to author option, to check this further?

Thanks,
Bharani, Google Ads API Team

ref:_00D1U1174p._5001UMWjWU:ref

Ben Foster

unread,
Nov 8, 2019, 6:27:29 PM11/8/19
to Google Ads API Forum Advisor Prod, adwor...@googlegroups.com
The CUSTOMER_NOT_ACTIVE error was what was resolved with the edit in the previous email. The problem was that I hadn’t specified a client_customer_id with the ManagedCustomerService.get() request.

Thanks for the response
--

--------------------------------------------
Ben Foster

Saltbox Solutions
email | b...@saltbox.solutions

Pratik Patel

unread,
May 28, 2020, 7:14:23 AM5/28/20
to AdWords API and Google Ads API Forum
Are you able to get CustomerService.getCustomers() without client_customer_id in header? strange! because i'm trying same in PHP sdk, but getting error CLIENT_CUSTOMER_ID_REQUIRED.

Google Ads API Forum Advisor Prod

unread,
May 28, 2020, 3:12:08 PM5/28/20
to p...@conversio.dk, adwor...@googlegroups.com

Hi Pratik,

Thank you for reaching out. It is required to provide the customer id to make calls to CustomerService.getCustomers(). You would need to provide it and the issue should be resolved.

Thanks and regards,
Xiaoming, Google Ads API Team



 

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