Hello,
My developer key was approved.
I had a client give me access via OAuth2. Have the access and refresh tokens.
Trying a very simple connection to list campaigns.
Getting an error: adspygoogle.adwords.AdWordsErrors.AdWordsAuthenticationError: [AuthorizationError.USER_PERMISSION_DENIED @ ; trigger:'<null>']
Can't figure out why I'm getting that error, or how to fix it.
Below is the code I'm using. (All data, keys, etc. are fake)
Any suggestions on how to troubleshoot/solve this??
Thanks!
=============================================
email = 'f...@bar.com'
client_customer_id = '123-456-789'
oauth2_client_id = '000000.apps.googleusercontent.com'
oauth2_client_secret = '00000000000000000000000'
developer_token = '00000000000000000000000'
access_token = '00000000000000000000000'
refresh_token = '00000000000000000000000'
# Build Credential object with our tokens
credentials = OAuth2Credentials("irrelevant access token",
oauth2_client_id, # Client ID
oauth2_client_secret,
refresh_token,
datetime.datetime.now(), # token expiry
"https://accounts.google.com/o/oauth2/token",
"test client")
# Create the AdWordsUser and set the OAuth2 credentials.
client = AdWordsClient(headers={
'developerToken': developer_token,
'clientCustomerId': client_customer_id,
'userAgent': 'OAuth2 Example',
'oauth2credentials': credentials
})
# OAuth2 credential objects can be refreshed via credentials.refresh() - the
# access token expires after 1 hour.
credentials.refresh(httplib2.Http())
print 'Credentials Refreshed!'
# Get all campaigns.
# Construct selector and get all campaigns.
campaign_service = client.GetCampaignService(version='v201302')
selector = {
'fields': ['Id', 'Name', 'Status']
}
campaigns = campaign_service.Get(selector)[0]
# Display results.
if 'entries' in campaigns:
for campaign in campaigns['entries']:
print ('Campaign with id \'%s\', name \'%s\' and status \'%s\' was found.'
% (campaign['id'], campaign['name'], campaign['status']))
else:
print 'No campaigns were found.'