Google Ads API - OAuth2 - PHP Error - authorization_error - "login-customer-id" header - GetCampaigns.php / ListAccessibleCustomers.php
With the "Google Ads API" - PHP Client Library.
While calling the "GetCampaigns.php
" / "ListAccessibleCustomers.php
" example code. I was still getting this error (below) but found a solution (check answer).
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
Fix -
Pass the Manager account's ID (in my case test manager account) = $loginCustomerId
->withLoginCustomerId($loginCustomerId)So in the “GoogleAdsClientBuilder” -
$googleAdsClient = (new GoogleAdsClientBuilder()) ->fromFile() ->withOAuth2Credential($oAuth2Credential) ->withLoginCustomerId($loginCustomerId) ->build();