RE: PERMISSION_DENIED/AUTHORIZATION_ERROR

90 views
Skip to first unread message
Message has been deleted

Google Ads API Forum Advisor

unread,
Oct 14, 2021, 5:02:21 AM10/14/21
to est...@networx.com, adwor...@googlegroups.com

Hi,

Thanks for posting your concern to us.

Thanks for reaching out to us. I had to delete your initial post as it contained your sensitive information. I am reposting below without the sensitive information for reference :

“Hi,

I'm using the PHP API.

We recently implemented conversion adjustments successfully, and now we're in the process of migrating the rest our system from Adwords API to Google Ads API.

The problem is that I am getting an authorization error that I am not getting with the conversion adjustments, even though I'm using the same credentials.

I put everything in one script to demonstrate this:

<?php

 

use \Google\AdsApi\Common\OAuth2TokenBuilder;

use \Google\Ads\GoogleAds\Lib\V8\GoogleAdsClientBuilder;

use \Google\Ads\GoogleAds\V8\Services\ConversionAdjustment;

use \Google\Ads\GoogleAds\Util\V8\ResourceNames;

use \Google\Ads\GoogleAds\V8\Enums\ConversionAdjustmentTypeEnum\ConversionAdjustmentType;

use \Google\Ads\GoogleAds\V8\Services\RestatementValue;

use \Google\Ads\GoogleAds\Util\V8\GoogleAdsFailures;

$oAuth2Credential = (new OAuth2TokenBuilder())

->fromFile(SYSTEM_BASEDIR.'/include/global/config/adsapi_php.ini')

->build();

$env = parse_ini_file(SYSTEM_BASEDIR.'include/global/config/adsapi_php.ini');

$googleAdsClient = (new GoogleAdsClientBuilder())

->withDeveloperToken($env['developerToken'])

->withLoginCustomerId(MAIN_ACCOUNT)

->withOAuth2Credential($oAuth2Credential)

->build();

/**************** CONVERSION ADJUSTMENT *****************/

$conversion_adjustment = new ConversionAdjustment([

'conversion_action' => ResourceNames::forConversionAction(MAIN_ACCOUNT, CONVERSION_ACTION_ID),

'adjustment_type' => ConversionAdjustmentType::RESTATEMENT,

'order_id'=>123456,

'adjustment_date_time' => date("Y-m-d H:i:sP", strtotime("-1 hour"))

]);

$conversion_adjustment->setRestatementValue(new RestatementValue([

'adjusted_value' => 25

]));

$conversionAdjustmentUploadServiceClient =

$googleAdsClient->getConversionAdjustmentUploadServiceClient();

$response = $conversionAdjustmentUploadServiceClient->uploadConversionAdjustments(

SUB_ACCOUNT,

[$conversion_adjustment],

true

);

if (!is_null($response->getPartialFailureError()))

{

echo "---------------- Conversion Adjusment Failure:\n";

$failure = GoogleAdsFailures::fromAny($response->getPartialFailureError()->getDetails()[0]);

 

foreach($failure->getErrors() as $error)

{

echo $error->getMessage()."\n";

}

}

/********************** REPORTING *********************/

$googleAdsServiceClient = $googleAdsClient->getGoogleAdsServiceClient();

$query =

"SELECT campaign.idcampaign.name FROM campaign ORDER BY campaign.id";

try {

$results = $googleAdsServiceClient->search(SUB_ACCOUNT, $query);

catch (Exception $e)

{

echo "\n----------------- Reporting Failure:\n";

echo $e->getMessage()."\n";

}

?>

The output of the script is:

---------------- Conversion Adjusment Failure:

This customer does not have a conversion action of a supported ConversionActionType that matches the conversion action provided.

----------------- Reporting Failure:

I'm not concerned with the conversion adjustment failure, since it's a dev account.

Please advise regarding the authorization error.

Thank you.



Could you provide us with the complete request and response logs with the request-id when you encountered the authorization error, so our team can better check?

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._5004Q2PJC9Q:ref
Reply all
Reply to author
Forward
0 new messages