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: [InternalApiError.UNEXPECTED_INTERNAL_API_ERROR @ com.google.ads.api.services.common.error.InternalApiError.<init>(InternalApiErro]
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 something like this:
# -*- coding: utf-8 -*-
from googleads import adwords
adwords_client = adwords.AdWordsClient.LoadFromStorage('C:\Python36\google_adwords.yaml')
ad_group_service = adwords_client.GetService('TargetingIdeaService', version='v201802')
selector = {
'ideaType': 'KEYWORD',
'requestType': 'IDEAS'
}
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: 1866
Reputation: 1246
I figured out my issue. I got my client_customer_id wrong. I was using the id from my test manager account, but this is incorrect. You need to MAKE a new test client adwords account INSIDE your test manager account:
After I clicked on that button, I was able to link the test client to my MCC Account (the account that has my test developer token) with the 'Invite users to this account' section:
Now I have linked my test account and my MCC Account.
I then pasted my test client adwords account id (xxx-xxx-xxxx) into the 'client_customer_id' section of my YAML file. I ran my script and found that I had successfully connected to the API!
Upvotes: 1