moveManagerLink - AUTHORIZATION_ERROR, Authorization of the client failed.

531 views
Skip to first unread message

Damian Szczepański

unread,
Jul 3, 2020, 8:13:28 PM7/3/20
to AdWords API and Google Ads API Forum
I'm trying to replace current manager 3191377543 with a new manager 6762660391 on client 9801005090. I'm getting following error:

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 139

My code:

namespace 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();


}

Google Ads API Forum Advisor Prod

unread,
Jul 6, 2020, 2:54:37 PM7/6/20
to in...@datadriventool.com, adwor...@googlegroups.com

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



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