Hello,

I am making use of the nikolajlovenhardt/laravel-google-ads 
<https://github.com/nikolajlovenhardt/laravel-google-ads> library for 
Laravel 5.

I set up  a product manager account and created an API key, requested the 
clientId, clientSecret and refreshToken.
I have setup a MCC test account, and notated its clientCustomerId.

But still, I'm getting "Authorized error".

My Adwords config:

<?php

return [
    'ADWORDS' => [
        'developerToken' => 'xxxxxxxxxxxxxxxx',
        'clientCustomerId' => 'xxx-xxx-xxx',

        /*
         * Optional. Set a friendly application name identifier.
         *
         * 'userAgent' => '',
         */

        /*
         * Optional additional AdWords API settings.
         * endpoint = "https://adwords.google.com/";
         *
         * 'isPartialFailure' => false,
         */

        /*
         * Optional setting for utility usage tracking in the user agent in 
requests.
         * Defaults to true.
         *
         * 'includeUtilitiesInUserAgent' => true,
         */
    ],

    'DFP' => [
        'networkCode' => '',
        'applicationName' => '',
    ],

    'ADWORDS_REPORTING' => [
        /*
         * Optional reporting settings.
         *
         * 'isSkipReportHeader' => false,
         * 'isSkipColumnHeader' => false,
         * 'isSkipReportSummary' => false,
         * 'isUseRawEnumValues' => false,
         */
    ],

    'OAUTH2' => [
        /*
         * Required OAuth2 credentials. Uncomment and fill in the values 
for the
         * appropriate flow based on your use case. See the README for 
guidance:
         * 
https://github.com/googleads/googleads-php-lib/blob/master/README.md#getting-started
         */

        /*
         * For installed application or web application flow.
        */
         'clientId' => 
'xxxxxxx-xxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com',
         'clientSecret' => 'xxxxxxxxxxxxxxxxxxxxxxx',
         'refreshToken' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxx',

        /*
         * For service account flow.
         * 'jsonKeyFilePath' => 
'INSERT_ABSOLUTE_PATH_TO_OAUTH2_JSON_KEY_FILE_HERE'
         * 'scopes' => 'https://www.googleapis.com/auth/adwords',
         */
    ],

    'SOAP' => [
        /*
         * Optional SOAP settings. See SoapSettingsBuilder.php for more 
information.
         * 'compressionLevel' => <COMPRESSION_LEVEL>,
         * 'wsdlCache' => <WSDL_CACHE>,
         */
    ],

    'PROXY' => [
        /*
         * Optional proxy settings to be used by SOAP requests.
         * 'host' => '<HOST>',
         * 'port' => <PORT>,
         * 'user' => '<USER>',
         * 'password' => '<PASSWORD>',
         */
    ],

    'LOGGING' => [
        /*
         * Optional logging settings.
         * 'soapLogFilePath' => 'path/to/your/soap.log',
         * 'soapLogLevel' => 'INFO',
         * 'reportDownloaderLogFilePath' => 
'path/to/your/report-downloader.log',
         * 'reportDownloaderLogLevel' => 'INFO',
         * 'batchJobsUtilLogFilePath' => 'path/to/your/bjutil.log',
         * 'batchJobsUtilLogLevel' => 'INFO',
         */
    ],
];


My Controller:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use LaravelGoogleAds\Services\AdWordsService;
use Google\AdsApi\AdWords\AdWordsServices;
use Google\AdsApi\AdWords\AdWordsSessionBuilder;
use Google\AdsApi\AdWords\v201609\cm\CampaignService;
use Google\AdsApi\AdWords\v201609\cm\OrderBy;
use Google\AdsApi\AdWords\v201609\cm\Paging;
use Google\AdsApi\AdWords\v201609\cm\Selector;

class AdwordsController extends Controller
{
    /** @var AdWordsService */
    protected $adWordsService;
    
    /**
     * @param AdWordsService $adWordsService
     */
    public function __construct(AdWordsService $adWordsService)
    {
        $this->adWordsService = $adWordsService;
    }

    public function index() {
    $test = $this->campaigns();

    //return dd($test);
    }

    public function campaigns()
    {
        $customerClientId = 'xxx-xxx-xxxx';

        $campaignService = 
$this->adWordsService->getService(CampaignService::class, 
$customerClientId);

        // Create selector.
        $selector = new Selector();

        $selector->setFields(array('Id', 'Name'));
        $selector->setOrdering(array(new OrderBy('Name', 'ASCENDING')));

        // Create paging controls.
        $selector->setPaging(new Paging(0, 100));

        // Make the get request.
        $page = $campaignService->get($selector);

        dd($page);
    }
}

But still it is giving me the following error:

<soap:Envelope 
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";><soap:Header><ResponseHeader
 
xmlns="https://adwords.google.com/api/adwords/cm/v201609";><requestId>00055adb54c6d2180a3781c64d0800fa</requestId><serviceName>CampaignService</serviceName><methodName>get</methodName><operations>1</operations><responseTime>78</responseTime></ResponseHeader></soap:Header><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>[AuthorizationError.USER_PERMISSION_DENIED
 
@ ; trigger:'&lt;null&gt;']</faultstring><detail><ApiExceptionFault 
xmlns="https://adwords.google.com/api/adwords/cm/v201609";><message>[AuthorizationError.USER_PERMISSION_DENIED
 
@ ; 
trigger:'&lt;null&gt;']</message><ApplicationException.Type>ApiException</ApplicationException.Type><errors
 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:type="AuthorizationError"><fieldPath></fieldPath><trigger>&lt;null&gt;</trigger><errorString>AuthorizationError.USER_PERMISSION_DENIED</errorString><ApiError.Type>AuthorizationError</ApiError.Type><reason>USER_PERMISSION_DENIED</reason></errors></ApiExceptionFault></detail></soap:Fault></soap:Body></soap:Envelope>


I would really appreciate your help. Thank you!

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
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 Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/c1e9f7d7-ab01-456f-ac62-b27733d7bffb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
  • Adwords API - L... Thomas in het Veld
    • Re: Adword... 'Shwetha Vastrad (AdWords API Team)' via AdWords API Forum

Reply via email to