Fatal error: Uncaught Google\ApiCore\ApiException: { "message": "The caller does not have permission", "code": 7, "status": "PERMISSION_DENIED", "details": [ { "@type": 0, "data": "type.googleapis.com\/google.ads.googleads.v3.errors.GoogleAdsFailure" }, { "@type": 0, "data": [ { "errorCode": { "authorizationError": "AUTHORIZATION_ERROR" }, "message": "Authorization of the client failed." } ] } ] } thrown in /home/dszomh/domains/app.datadriventool.com/public_html/libraries/google-ads/vendor/google/gax/src/ApiException.php on line 139namespace Google\Ads\GoogleAds\V3\Services\Gapic;
include($_SERVER['DOCUMENT_ROOT'].'/libraries/google-ads/vendor/autoload.php');
use Google\Ads\GoogleAds\V3\Services\CustomerManagerLinkServiceClient;
use GetOpt\GetOpt;
use Google\Ads\GoogleAds\Examples\Utils\ArgumentNames;
use Google\Ads\GoogleAds\Examples\Utils\ArgumentParser;
use Google\Ads\GoogleAds\Lib\V3\GoogleAdsClient;
use Google\Ads\GoogleAds\Lib\V3\GoogleAdsClientBuilder;
use Google\Ads\GoogleAds\Lib\V3\GoogleAdsException;
use Google\Ads\GoogleAds\Lib\OAuth2TokenBuilder;
use Google\Ads\GoogleAds\V3\Errors\GoogleAdsError;
use Google\Ads\GoogleAds\V3\Resources\Customer;
use Google\ApiCore\ApiException;
use Google\Protobuf\BoolValue;
use Google\Protobuf\StringValue;
$refresh_token = '1//0c5B...';
$customerId = '9801005090';
$newManager = 'customers/6762660391';
$oAuth2Credential = (new OAuth2TokenBuilder())
->fromFile()
->withRefreshToken($refresh_token)
->build();
$googleAdsClient = (new GoogleAdsClientBuilder())->fromFile()->withOAuth2Credential($oAuth2Credential)->build();
$customerManagerLinkServiceClient = $googleAdsClient->getCustomerManagerLinkServiceClient();
try {
$previousCustomerManagerLink = "customers/9801005090/customerManagerLinks/3191377543~182140507";
$response = $customerManagerLinkServiceClient->moveManagerLink($customerId, $previousCustomerManagerLink, $newManager);
print_r($response);
} finally {
$customerManagerLinkServiceClient->close();
}Hi Damian,
Thank you for reaching out. The PERMISSION_DENIED error indicates that you are authorized as a user that does not have access to the account in which you are making the API request towards. Can you please provide the email address that is authenticating the API call via the "Reply privately to author" option? Additionally, can you ensure that this email address is added as a user in the client account (9801005090)? You can check by going to Tools & Settings -> Account access.
Regards,
Danica, Google Ads API Team