![]() |
Google Ads API Team |
Here is the information you requested:
Customer IDs: 6031131558, 3682675394, 1327857499, 7627068296, 9604076790, 8995827941, 8068169535, 3498279900
Client ID: 1000434119396-339j164s0u76nopod9g67upidb48qsc0.apps.googleusercontent.com
MCC Client ID: 7588864995
Developer Token: SrbSEzImJXJCTKe7EumqAw
Here is the cURL request that I made:
curl --location 'https://googleads.googleapis.com/v17/customers/5169753570/googleAds:search' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ya29.a0AcM612y1gzcJFzWnFZ56Ns2TSQ2lMNKj8NMJBDCeuGfnFJfiXUlUYxMEaefqVSSfTRKjREwZcgB_Fymp1dU1ZoGxPmNL-8Ywim1Ebx-3akGShUoF1BnB1-adbX0oF2S9eVpJFUm2jx9-Q2ihRE3BmKalmhydOsfG0xynsMegKHYaCgYKAd8SARASFQHGX2MiXJItx4at6_GSDlSav4AlRw0178' \
--header 'developer-token: SrbSEzImJXJCTKe7EumqAw' \
--header 'login-customer-id: 7588864995' \
--data '{
"query": "SELECT customer_client.client_customer FROM customer_client"
}'
Here is the response from the above request:
{
"error": {
"code": 403,
"message": "The caller does not have permission",
"status": "PERMISSION_DENIED",
"details": [
{
"@type": "type.googleapis.com/google.ads.googleads.v17.errors.GoogleAdsFailure",
"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/google-ads/api/docs/concepts/call-structure#cid"
}
],
"requestId": "PbbpudCOzjEILROzAkbmPQ"
}
]
}
}
Here is the simple code that I use to fetch customer data:
from google.ads.googleads.client import GoogleAdsClient
# Replace with your actual credentials (avoid sharing sensitive info)
credentials = {
"client_id": "1000434119396-339j164s0u76nopod9g67upidb48qsc0.apps.googleusercontent.com",
"client_secret": "*********************************",
"login-customer-id": 7588864995,
"refresh_token": "*******************************************",
"developer_token": "SrbSEzImJXJCTKe7EumqAw",
"use_proto_plus": True
}
# Initialize the client
client = GoogleAdsClient.load_from_dict(credentials)
# Get the service
googleads_service = client.get_service("GoogleAdsService")
# Set the customer ID for the query
customer_id = "5169753570" # Use string format
# Query to list all accounts managed by the MCC
query = """
SELECT
customer_client.client_customer,
customer_client.level
FROM
customer_client
"""
try:
# Use the MCC ID here to list all client accounts
response = googleads_service.search_stream(customer_id=customer_id, query=query)
for batch in response:
for row in batch.results:
print(f"Client Customer ID: {row.customer_client.client_customer}, Level: {row.customer_client.level}")
except Exception as e:
print(f"Error: {e}")