How to retrieve Client Customer ID from API (Python)?

386 views
Skip to first unread message

Chris London

unread,
Sep 8, 2020, 7:06:32 PM9/8/20
to AdWords API and Google Ads API Forum
I've set up OAuth2 and I'm able to get credentials to access the API but there seems to be a gap in the documentation on retrieving the `client_customer_id`.


I know that I can manually log into my AdWords account and find my ID on the top but that's cumbersome for users. I was hoping when the user accepts to give me access to their  AdWords there would be a way to programmatically get the client_customer_id.

Here's an example of my code:

```
oauth2_client = oauth2.GoogleRefreshTokenClient(
    os.environ.get("ADWORDS_CLIENT_ID"),
    os.environ.get("ADWORDS_CLIENT_SECRET"),
    account.refresh_token,  # Refresh token from OAuth2
)

# Initialize the AdWords client.
adwords_client = adwords.AdWordsClient(
    os.environ.get("ADWORDS_DEVELOPER_TOKEN"), 
    oauth2_client,
    os.environ.get("ADWORDS_USER_AGENT"), 
    # We don't know the client_customer_id yet
)

customer_service = adwords_client.GetService(
    "CustomerService", version="v201809"
)
customers = customer_service.getCustomers()
```

When I do that I get this error:
googleads.errors.GoogleAdsServerFault: [AuthenticationError.CUSTOMER_NOT_FOUND @ ]

Is there a way to programmatically retrieve the client_customer_id without having to ask the customer to manually enter it?

Google Ads API Forum Advisor Prod

unread,
Sep 9, 2020, 5:01:07 PM9/9/20
to clo...@cinch.io, adwor...@googlegroups.com
Hi Chris,

Thanks for reaching out! If you are trying to use CustomerService without specifying a customer ID in your request, you will not be able to make the request. If you do not know the customer ID, then you will have to get it manually from the UI. However, if you are the manager of the customer, then you can specify your manager ID in the request to get a list of customers under your management. 

Regards,
Google Logo
Danica
Google Ads API Team
 


ref:_00D1U1174p._5004Q24ZrNd:ref

mansur ksa

unread,
Sep 12, 2020, 1:54:41 PM9/12/20
to clo...@cinch.io, AdWords API and Google Ads API Forum


‫أُرسلت من الـ iPhone‬

‫في ٠٩‏/٠٩‏/٢٠٢٠ الساعة ٢:٠٦ ص، كتب/كتبت ‏Chris London ‏<clo...@cinch.io>:‬

I've set up OAuth2 and I'm able to get credentials to access the API but there seems to be a gap in the documentation on retrieving the `client_customer_id`.
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwor...@googlegroups.com
To unsubscribe from this group, send email to
adwords-api...@googlegroups.com
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 and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/7a730841-5539-433f-b867-c3ef00cd6ef3n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages