AuthorizationError USER_PERMISSION_DENIED

53 views
Skip to first unread message

Dimitar Hristonev

unread,
Feb 13, 2018, 5:46:09 AM2/13/18
to AdWords API Forum
Hi guys,
I'm trying to connect customer accounts to web server in php.
First I creating client with my app. Getting refresh/access token. Save them to DB.
After that I'm trying to get report, unsuccessfuly.
I'm getting customer credentials via
$client = new Google_Client();
$client->setAccessType("offline");
$client->setAuthConfig('client.json');
$client->addScope("https://www.googleapis.com/auth/adwords");
$client->setRedirectUri('http://' . $_SERVER['HTTP_HOST'] . '/api/connect/adwords.php');

$client->fetchAccessTokenWithAuthCode($_GET['code']);

$clientId = $client->getClientId();
$clientSecret = $client->getClientSecret();
$accessToken = $client->getAccessToken();
$refreshToken = $client->getRefreshToken();
//STORE TO DB

After that my code is:
$reportSettings = (new \Google\AdsApi\AdWords\ReportSettingsBuilder())
    ->includeZeroImpressions(false)
    ->skipColumnHeader(false)
    ->skipReportHeader(true)
    ->skipReportSummary(true)
    ->build();

$credentials = (new \Google\AdsApi\Common\OAuth2TokenBuilder())
    ->withClientId($client_id)
    ->withClientSecret($client_secret)
    ->withRefreshToken($refresh_token)
    ->build()
;

$session = (new \Google\AdsApi\AdWords\AdWordsSessionBuilder())
    ->withDeveloperToken("app_dev_token")
    ->withClientCustomerId("app_customer_id")
    ->withUserAgent("app_agent")
    ->withOAuth2Credential($credentials)
    ->withReportSettings($reportSettings)
    ->build()
;

$reportDownloader = new \Google\AdsApi\AdWords\Reporting\v201705\ReportDownloader($session);



Dhanya Sundararaju (AdWords API Team)

unread,
Feb 13, 2018, 3:45:20 PM2/13/18
to AdWords API Forum
Hi Dimitar,

USER_PERMISSION_DENIED implies that there is no link between the manager account authenticated in the request and the client account specified in the headers, which means the authenticating user is not having access to the target account. Could you enable logging and share the complete SOAP logs along with the email Id of the authenticating user?

Regards,
Dhanya, AdWords API Team
Reply all
Reply to author
Forward
0 new messages