Hi

*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}")

On Thu, Sep 19, 2024 at 6:53 PM Google Ads API Forum Advisor <
adsapi@forumsupport.google> wrote:

> Hi,
>
> Thank you for reaching out to the Google Ads API support team.
>
> I could see that you are encountering a USER_PERMISSION_DENIED
> <https://developers.google.com/google-ads/api/reference/rpc/v14/AuthorizationErrorEnum.AuthorizationError#user_permission_denied>
>  authorization
> error, it means the user doesn't have permission to access the customer.
> According to the documentation
> <https://developers.google.com/google-ads/api/docs/best-practices/common-errors#:~:text=USER_PERMISSION_DENIED>,
> if you're accessing the customer, please specify the login-customer-id as
> the manager account ID without hyphens (-). Also, kindly check if you have
> the correct access level
> <https://support.google.com/google-ads/answer/9978556?visit_id=637628826037447236-382779227&rd=1>
>  to
> the Google Ads account that you are accessing. Kindly note that only error
> logs are not sufficient to assist you.
>
> To analyze your issue further could you kindly provide us with the below
> details.
>
>    - Execute List Accessible Customers
>    
> <https://developers.google.com/google-ads/api/samples/list-accessible-customers>
>  and
>    provide us complete API request and response logs, you may also check this 
> API
>    documentation
>    
> <https://developers.google.com/google-ads/api/docs/account-management/listing-accounts>
>  for
>    more information.
>    - The user email is used for generating the OAuth credentials i.e,
>    refresh token.
>    - Complete API logs (request
>    
> <https://developers.google.com/google-ads/api/docs/concepts/field-service#request>
>     and response
>    
> <https://developers.google.com/google-ads/api/docs/concepts/field-service#response>
>     with request-id
>    
> <https://developers.google.com/google-ads/api/docs/concepts/call-structure#request-id>
>     and request header
>    
> <https://developers.google.com/google-ads/api/docs/concepts/call-structure#request_headers>)
>    generated at your end.
>
> If you are using a client library and haven't enabled the logging yet, I
> would request you to enable logging for the specific client library that
> you are using. You can refer to the guides *Java*
> <https://developers.google.com/google-ads/api/docs/client-libs/java/logging>
> , *.Net*
> <https://developers.google.com/google-ads/api/docs/client-libs/dotnet/logging>
> , *PHP*
> <https://developers.google.com/google-ads/api/docs/client-libs/php/logging>
> , *Python*
> <https://developers.google.com/google-ads/api/docs/client-libs/python/logging>
> , *Ruby*
> <https://developers.google.com/google-ads/api/docs/client-libs/ruby/logging>
>  or *Perl*
> <https://developers.google.com/google-ads/api/docs/client-libs/perl/logging> 
> to
> enable logging at your end. For REST interface requests, you can enable
> logging via the curl command by using the -i flag.
>
> You can send the details via *Reply privately to the author option*, or 
> *direct
> private reply* to this email.
>
> This message is in relation to case
> "ref:!00D1U01174p.!5004Q02vGLWz:ref" (ADR-00268747)
>
> Thanks,
>
> [image: Google Logo] Google Ads API Team
>
>
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@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 
"Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/CAE-0ESRcDV5CixVCd2qbJ20p%3DMXiNkNQLFWgrksHBaXuFhqa-g%40mail.gmail.com.
  • PE... Developer Walkwel
    • ... 'Google Ads API Forum Advisor' via Google Ads API and AdWords API Forum
      • ... Developer Walkwel

Reply via email to