Reputation: 1246
I'm trying to use the Google Adwords Test API. I'm trying to connect to the Google Adwords API, but I keep getting the following error:
googleads.errors.GoogleAdsServerFault: [AuthenticationError.CLIENT_CUSTOMER_ID_IS_REQUIRED @ ; trigger:'<null>']
I've made a Google Adwords Production Account in order to get the developer API key. I've then made a Google Adwords Manager Test account and managed to get a Oauth Client id, and Secret Id. I then used the Google Oauth 2.0 playground to get the refresh token. My google_adwords.yaml file now looks something like this:
# AdWordsClient configurations
adwords:
#############################################################################
# Required Fields #
#############################################################################
developer_token: **DEVELOPER TOKEN FROM PRODUCTION ACCOUNT PASTED HERE**
#############################################################################
# Optional Fields #
#############################################################################
# client_customer_id: **CLIENT CUSTOMER ID FROM MANAGER TEST ACCOUNT PASTED HERE**
# user_agent: INSERT_USER_AGENT_HERE
# partial_failure: True
# validate_only: True
#############################################################################
# OAuth2 Configuration #
# Below you may provide credentials for either the installed application or #
# service account flows. Remove or comment the lines for the flow you're #
# not using. #
#############################################################################
# The following values configure the client for the installed application
# flow.
client_id: **CLIENT ID FROM MANAGER TEST ACCOUNT PASTED HERE**
client_secret: **CLIENT CUSTOMER SECRET FROM MANAGER TEST ACCOUNT PASTED HERE**
refresh_token: **REFRESH TOKEN FROM OAUTH PLAYGROUND ON BEHALF OF MANAGER TEST ACCOUNT PASTED HERE**
# The following values configure the client for the service account flow.
# path_to_private_key_file: INSERT_PATH_TO_JSON_KEY_FILE_HERE
# delegated_account: INSERT_DOMAIN_WIDE_DELEGATION_ACCOUNT
#############################################################################
# ReportDownloader Headers #
# Below you may specify boolean values for optional headers that will be #
# applied to all requests made by the ReportDownloader utility by default. #
#############################################################################
# report_downloader_headers:
# skip_report_header: False
# skip_column_header: False
# skip_report_summary: False
# use_raw_enum_values: False
My Python code looks like this:
from googleads import adwords
adwords_client = adwords.AdWordsClient.LoadFromStorage('C:\Python36\google_adwords.yaml')
ad_group_service = adwords_client.GetService('TargetingIdeaService', version='v201806')
selector = {
'ideaType': 'KEYWORD',
'requestType': 'IDEAS'
}
selector['requestedAttributeTypes'] = [
'KEYWORD_TEXT', 'SEARCH_VOLUME', 'CATEGORY_PRODUCTS_AND_SERVICES']
offset = 0
selector['paging'] = {
'startIndex': str(offset),
'numberResults': str(5)
}
selector['searchParameters'] = [{
'xsi_type': 'RelatedToQuerySearchParameter',
'queries': ['dog']
}]
page = ad_group_service.get(selector)
print (page)
Does anyone know where I'm going wrong? I reckon there is something wrong with my YAML file, but can't quite place what it may be. Thanks in advance.
Upvotes: 0
Views: 369
Reputation: 6292
You'll need to uncomment the client_customer_id
line in your configuration file and insert the ID of the Test Account you created.
The item is marked optional because there is a single service CustomerService
that does not require it—rather, CustomerService
allows you to retrieve the IDs of the accessible accounts for the authenticated user.
But for all other services, including TargetingIdeaService
, which you want to access, it's a required setting.
Upvotes: 1