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;
const MAIN_ACCOUNT = 1111111111;
const SUB_ACCOUNT = 2222222222;
const CONVERSION_ACTION_ID = 333333333;
$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.id, campaign.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:
{
"message": "The caller does not have permission",
"code": 7,
"status": "PERMISSION_DENIED",
"details": [
{
"@type": 0,
"data":
"type.googleapis.com\/google.ads.googleads.v8.errors.GoogleAdsFailure"
},
{
"@type": 0,
"data": [
{
"errorCode": {
"authorizationError": "AUTHORIZATION_ERROR"
},
"message": "Authorization of the client failed."
}
]
},
{
"@type": 0,
"data": "78NI7HKIqEHMk8aFSsbcWg"
}
]
}
I'm not concerned with the conversion adjustment failure, since it's a dev
account.
Please advise regarding the authorization error.
Thank you.
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/adwords-api/3008202f-a674-4ee6-a6c0-2bf1fc30d944n%40googlegroups.com.