Analytics
1.8K members online now
Discuss discrepancies between AdWords and Google Analytics data, linking AdWords and Google Analytics, importing your goals/Ecommerce transactions into AdWords, and setting up Remarketing
 
Guide Me
star_border
Reply

third party user permission denied

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

how to get refresh token for other user with grant access permission for create session.
i want to use that session in report downloader. in google adwords api.

Below is my code which I use for getting GoogleAdward data of only my a/c. I need to get thirdparty client Adward report so please suggest me how can I get that thirdparty client Adward report.
Also give me code example and proper guidence for access Thirdparty client Adwardreport.

$refresh_token = "1/s6M22TMfgFHw4LxgPQ2PdpFuLWZ_Ica3i2Rpbs0NlveFlrmSMElBNcaix8Qr6-8Q";
$configIniFilePath = "adsapi_php.ini";

$customerId = "263-131-4868";

$oauth2_clientId = "1066774173759-vkbl59ldbl6mh6nogfalus4mkm85j1hv.apps.googleusercontent.com";
$oauth2_clientSecret = "8IL9O2RDVA9wBjTAtB6341-g"; // set client secret
$oAuth2Credential = (new OAuth2TokenBuilder())->fromFile($configIniFilePath);


$oAuth2Credential->withClientId($oauth2_clientId);
$oAuth2Credential->withClientSecret($oauth2_clientSecret);
$oAuth2Credential->withRefreshToken($refresh_token);

$credential = $oAuth2Credential->build();

$reportSettings = (new ReportSettingsBuilder())
->fromFile($configIniFilePath)
->includeZeroImpressions(false)
->build();

$session = (new AdWordsSessionBuilder())
->fromFile($configIniFilePath)
->withOAuth2Credential($credential) // set credentials using credentialBuilder() function
->withClientCustomerId($customerId) // set client customer ID
->withReportSettings($reportSettings)
->build();

$selector = new Selector();
$selector->setFields(['ActiveViewImpressions','AccountCurrencyCode','CostPerConversion','Clicks','Impressions','Ctr','AverageCpc', 'Cost', 'AveragePosition','Conversions','Date']);
$selector->setPredicates([new Predicate('Status', PredicateOperator::NOT_IN, ['PAUSED'])]);

$reportDefinition= new ReportDefinition(); // Create report definition.
$reportDefinition->setSelector($selector);
$reportDefinition->setReportName('Criteria performance report #'.uniqid());
$reportDefinition->setDateRangeType(ReportDefinitionDateRangeType::LAST_7_DAYS);

$reportDefinition->setReportType(ReportDefinitionReportType::CRITERIA_PERFORMANCE_REPORT);// report type
$reportDefinition->setDownloadFormat(DownloadFormat::CSV);

$reportDownloader = new ReportDownloader($session);
$reportDownloadResult = $reportDownloader ->downloadReport($reportDefinition);
$reportAsString = $reportDownloadResult->getAsString();

echo "<pre>";
print_r($reportAsString);