google ads api fails with python

145 views
Skip to first unread message

Anushri shanbhag

unread,
May 18, 2019, 9:15:08 AM5/18/19
to AdWords API and Google Ads API Forum
Following is what I tried ;

1. Created a manager ( production account) and created a  developer token .
2. created a test manager account
3. Created credentials, project in test account. 
4. Requested oath refresh token with test credentials. 
5. updated the google-ads.yaml file  file with 
 
developer_token: From manager production account 
client_id:             test manager account
client_secret:      test manager account
refresh_token:    generated as mentioned providing test manager id

login-customer-id :  manager production account without hypen (-)

But when I run the basic get_ca mpaigns.py  I get 
Fault: {
  "errors": [
    {
      "errorCode": {
        "authorizationError": "USER_PERMISSION_DENIED"
      },
      "message": "User doesn't have permission to access customer. Note: If you're accessing a client customer, the manager's customer id must be set in the 'login-customer-id' header. See https://developers.google.com/goo
gle-ads/api/docs/concepts/call-structure#login-customer-id"
    }
  ]
}


Can anyone help please ?

Andre Tannus

unread,
May 18, 2019, 9:34:46 AM5/18/19
to AdWords API and Google Ads API Forum
Hi there.
 
developer_token: From manager production account 
client_id:             test manager account
client_secret:      test manager account
refresh_token:    generated as mentioned providing test manager id

The client_secret is not the account number.
It should be an alpha-numeric string.
I think you get it along with the refresh token.

Anushri shanbhag

unread,
May 18, 2019, 12:08:21 PM5/18/19
to AdWords API and Google Ads API Forum
Client_secret I have used the one displayed in credentials page of test manager account  along with client id 
adsapi.PNG

Andre Tannus

unread,
May 18, 2019, 1:00:18 PM5/18/19
to AdWords API and Google Ads API Forum
Do this checklist:

- You have a valid set of credentials obtained for the test account. Remember, the developer token is global (for both test and production) but client_id, client_secret and refresh_token are local to either test OR production accounts.
- You are logging in with the test account id (the xxx-xxx-xxxx code you get from you test manager account)
- You are trying to get campaigns from a child account of the test account (not the production account)

If you check all of the above, it should be working. Make sure that if you're accessing a child account directly you still need to send the manager id, as it is mentioned in the error message.

"message": "User doesn't have permission to access customer. Note: If you're accessing a client customer, the manager's customer id must be set in the 'login-customer-id' header. See https://developers.google.com/goo
gle-ads/api/docs/concepts/call-structure#login-customer-id"

Also, check your logs, maybe there will be more information here.

André 

Anushri shanbhag

unread,
May 18, 2019, 2:24:45 PM5/18/19
to AdWords API and Google Ads API Forum
Thanks Andre. I am still not able to figure out what am I doing wrong. 

Could you please help clarify the following 

On the  "test" account that you mention. I have created a test manager account . 

1.  Do I need to create another test account under it  ?
2.  Meanwhile, I also  tried to create another account under test manager account. "testacc" as in the attachment.
3.  I see the red "X" mark and I see if I refresh the page, the account is not listed and if I use the account number however, it still gets back with the same error . 

Can you please elaborate on the test setup ? 
Also,  please let me know which language did it work for you . Also did it work for you in python anytime ? 

I am totally stuck on this , any help would be appreciated. 

Thanks and Regards,
Vinutha
testacc_creation.PNG

Andre Tannus

unread,
May 18, 2019, 5:00:27 PM5/18/19
to AdWords API and Google Ads API Forum
Let's see...
 
On the  "test" account that you mention. I have created a test manager account . 
1.  Do I need to create another test account under it  ?

I believe so. It is probably possible to access data directly from the Manager account, but what I do is access the managed accounts (by CustomerId) directly.
Either way, you can only access data from accounts under your Manager Account, i.e. while using Test credentials, you'll only be able to interact with accounts under the Test account.
You should create a fresh account under the Test Manager Account (apparently you already have done that). Try to manually create a campaign there (via Google Ads) and then try to pull it from the API.
Don't put production accounts under your test account. I'm not sure it's even possible, but test accounts will never be able to run ads in real life, so watch out.

2.  Meanwhile, I also  tried to create another account under test manager account. "testacc" as in the attachment.

Good.
 
3.  I see the red "X" mark and I see if I refresh the page, the account is not listed and if I use the account number however, it still gets back with the same error .

That red "X" means the account has been canceled. It should be a green circle for an active account.

Check the settings bellow to enable displaying canceled and hidden accounts.

google-ads-help.png


 
Can you please elaborate on the test setup ? 
Also,  please let me know which language did it work for you . Also did it work for you in python anytime ? 

I use the PHP library. In them, the examples require you to set a CustomerId, I didn't see that in the Python examples, it seems they load that information from file (perhaps the yaml config).

The error you're getting means you're trying to access an account to which you don't have access.

Remember that the Manager account needs to have full access to the Managed account. In the past, you needed to either:

1. Create the new account from within the Manager account - or
2. Request access from the Manager account to the child account, then grant the access in the child account. I remember having trouble using the API when the child account invited the Manager account, it has to be the other way around.
 
I am totally stuck on this , any help would be appreciated. 

It took me a couple of days to get going too, there's a lot to take in. Maybe get some sleep, work out a little, blow off steam, and start fresh. That always helps me.

André

Google Ads API Forum Advisor Prod

unread,
May 19, 2019, 11:22:18 PM5/19/19
to adwor...@googlegroups.com
Hi Anushri,

Thank you for reaching out. Sorry for the delayed response.

The credentials in your .yaml file seem correct. However, since you are using your test manager account, kindly use the account id of your test manager account in the login-customer-id field. Let me know if this solves your problem. 

Also, test client accounts will appear as cancelled accounts in the UI. However, they are not really cancelled. 

Regards,
Dannison
Google Ads API Team

ref:_00D1U1174p._5001UAq0VQ:ref

Anushri shanbhag

unread,
May 20, 2019, 5:02:54 AM5/20/19
to AdWords API and Google Ads API Forum
Hi, 

Thank you. Let me try with the same.

Anushri shanbhag

unread,
May 20, 2019, 5:04:38 AM5/20/19
to AdWords API and Google Ads API Forum
Thanks Andre.  I appreciate your continuous support. 

I am asked to modify the login-customer-id  from production manger account to that of test manager account.  I am trying with that.  Meanwhile I am also following up on issue with client account creation 
under test manager account.

Will update with the result after my trial. Hopefully something positive !!

Thanks and Regards,
Anushri

Anushri shanbhag

unread,
May 22, 2019, 2:47:38 AM5/22/19
to AdWords API and Google Ads API Forum
After modifying the login-customer-id to that of test manager account. The issue got solved. Thank you everyone !!
Reply all
Reply to author
Forward
0 new messages