Hi!
I'm trying to invite customers to my manage account using
ManagedCustomerService and accept that invitation on behalf of the customer
using this
https://github.com/googleads/googleads-python-lib/wiki/API-access-on-behalf-of-your-clients-(web-flow)
example.
Here is my code:
`flow = client.OAuth2WebServerFlow(
client_id=g_appID,
client_secret=g_secret,
scope=oauth2.GetAPIScope('adwords'),
user_agent='Pata',
redirect_uri='http://127.0.0.1:5000/get_Gtoken')
code = request.args['code']
credentials = flow.step2_exchange(code)
print credentials.to_json()
oauth2_client = oauth2.GoogleRefreshTokenClient(
credentials.client_id, credentials.client_secret, credentials.refresh_token)
# getting customer_id
adwords_client = adwords.AdWordsClient(g_devToken, oauth2_client)
customer = adwords_client.GetService('CustomerService',
version='v201609').getCustomers()
customer_id = customer[0]['customerId']
print customer_id
# inviting customer with my manage acc
adwords_manager = adwords.AdWordsClient.LoadFromStorage('googleads.yaml')
managed_customer_service = adwords_manager.GetService('ManagedCustomerService',
version='v201609')
operations = [{
'operator': 'ADD',
'operand': {
'managerCustomerId': adwords_manager.client_customer_id,
'clientCustomerId': customer_id,
'linkStatus': 'PENDING',
}
}]
managed_customer_service.mutateLink(operations)
# accepting invitation on behalf of the customer
adwords_client2 = adwords.AdWordsClient(g_devToken, oauth2_client,
client_customer_id=customer_id)
managed_customer_service2 =
adwords_client2.GetService('ManagedCustomerService', version='v201609')
selector = {
'managerCustomerIds': adwords_manager.client_customer_id,
'clientCustomerIds': adwords_client2.client_customer_id
}
page = managed_customer_service2.getPendingInvitations(selector)
print page`
I'm getting '[ManagedCustomerServiceError.NOT_AUTHORIZED @ ]' error after
page = managed_customer_service2.getPendingInvitations(selector)
That seems strange for me, because if I replace last step to this:
campaign_service = adwords_client2.GetService('CampaignService',
version='v201609')
selector = {
'fields': ['Id', 'Name', 'Status'],
'paging': {
'startIndex': str(0),
'numberResults': str(100)
}
}
page = campaign_service.get(selector)
for campaign in page['entries']:
print campaign['id']`
I'm successfully getting all customer's campaigns.
What am I doing wrong?
Is it forbidden to automatically accept invitation?
P.S. That invitation is also successfully displayed in both of Adwords
cabinets.
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords 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 Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit
https://groups.google.com/d/msgid/adwords-api/b39011a4-b4de-4b4e-aa0c-f34011536241%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.