authorization_error: User doesn't have permission to access customer

56 views
Skip to first unread message

Miguel Angel Calleja

unread,
Apr 27, 2022, 5:02:35 AM4/27/22
to Google Ads API and AdWords API Forum
Hi
PHP 8
Google Ads V9 => 13.0.0

Im getting the Customer Manager Links from my account 6765096429:

Array
        (
            [resource_name] => customers/6765096429/customerManagerLinks/2508518472~216663108
            [status] => ACTIVE
            [manager_customer] => customers/2508518472
            [manager_link_id] => 216663108
        )

At the next step I want to query the Customer Client "customers/2508518472" to get their descriptiveName but I receive an authorization error:

authorization_error: 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

Im passsing the customer 6765096429 like customer_login_id in the credentials:

$oAuth2Credential = (new OAuth2TokenBuilder())
->withClientId($client_id)
->withClientSecret($secret)
->withRefreshToken($refresh_token)
->build();

$googleAdsClient = (new GoogleAdsClientBuilder())
->withDeveloperToken($developer_token)
->withOAuth2Credential($oAuth2Credential)
->withLoginCustomerId(6765096429)
->build();

// Here, I query customer client 2508518472 to get the descriptiveName
$customerId=2508518472;
$query = 'SELECT customer_client.client_customer, customer_client.level,'
. ' customer_client.manager, customer_client.descriptive_name,'
. ' customer_client.currency_code, customer_client.time_zone,customer_client.test_account,'
. ' customer_client.id FROM customer_client
limit 1';
$googleAdsServiceClient = $googleAdsClient->getGoogleAdsServiceClient();
$customer = $googleAdsServiceClient->search($customerId, $query)->getIterator()->current()->getCustomerClient();

print "name: ".$customer->getDescriptiveName();

At this point I receive the authorization_error

What am I doing wrong?

Best regards




Google Ads API Forum Advisor

unread,
Apr 27, 2022, 1:09:27 PM4/27/22
to mang...@gmail.com, adwor...@googlegroups.com
Hi Miguel,

Thank you for reaching out.

To investigate the issue further, could you please provide the complete request and response logs, with the request-id? If you haven't yet, logging can be enabled by navigating to the Client libraries > Your client library (ex. Java) > Logging documentation, which you can access from this link. You can provide it via Reply privately to author option. If this option is not available, then send it instead on this email address googleadsa...@google.com.

Thanks,

Google Logo
Nirmita
Google Ads API Team
 


 

ref:_00D1U1174p._5004Q2aO1U0:ref
Reply all
Reply to author
Forward
0 new messages