PERMISSION_DENIED and login-customer-id

88 views
Skip to first unread message

Antonio Paricio

unread,
Jul 22, 2021, 7:07:25 AM7/22/21
to AdWords API and Google Ads API Forum
Hello,

I try to connect into my adwords account using the googleads/google-ads-php library.
I'm capable to get a token and this token has the adwords scope but, when I try to get campaigns I get a PERMISSION_DENIED exception.

Google Ads failure details:
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
I put my login-customer-id in my client like that:

$oAuthCredential = (new OAuth2TokenBuilder())
            ->withClientId($options->getClientId())
            ->withClientSecret($options->getClientSecret())
            ->withRefreshToken($options->getRefreshToken())
            ->build();

        $client = (new GoogleAdsClientBuilder())
            ->withDeveloperToken($options->getDeveloperToken())
            ->withOAuth2Credential($oAuth2Credential)
    ->withLoginCustomerId($loginCustomerId)
            ->build();
            
Where $loginCustomerId is my googleads MCC ID. I get this when I login with my googleads account (same email where I have my client) and select an account. I put this number without dashes.

And when I try to get campaigns I do this:

$stream = $client->getGoogleAdsServiceClient()
                ->searchStream($this->gaOptions->getCustomerId(), $query);
        $stream->iterateAllElements();
        
Where customerId is the ID of my account inside my MCC wihtout dashes.

But then I get that PERMISSION_DENIED.

I'm using the V6 versión of the googleads/google-ads-php. This is the highest I can use because some dependencies.

My code is based in 

I see requests in Google Cloud Console but always with a 4XX code. I think is an error in the way I put my loginCustomerId and/or customerId, but I cannot find the reason why. ¿Do I need add something to my oAuthCredential or GoogleAdsClient? ¿Could be I using this IDs in the wrong way?

Thanks

Google Ads API Forum Advisor

unread,
Jul 22, 2021, 9:54:32 PM7/22/21
to antonio...@semmantica.com, adwor...@googlegroups.com

Hi Antonio,

Thanks for reaching out to us.

Could you please provide us with the following information so we could investigate further?

  1. Request logs
  2. Response logs
  3. Request ID

If you haven't yet, logging can be enabled by navigating to the Client libraries > Your client library (ex. PHP) > Logging documentation, which you can access from this link. You may then send the requested information via the Reply privately to author option. If this option is not available, you may send the details directly to our googleadsa...@google.com alias instead.

Regards,
 

Google Logo
Yasar
Google Ads API Team
 


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