Edujugon / laravel-google-ads

Google Adwords API for Laravel
MIT License
68 stars 23 forks source link

AuthenticationError.OAUTH_TOKEN_INVALID #46

Open dee2499 opened 5 years ago

dee2499 commented 5 years ago

Gettting this error, this is the google-ads.php.

It says OAUTH_TOKEN_INVALID.

<?php
return [
    //Environment=> test/production
    'env' => 'test',
    //Google Ads
    'production' => [
        'developerToken' => "0HZ-----------R7g",
        'clientCustomerId' => "10--------8",
        'userAgent' => "Name",
        'clientId' => "92----------.apps.googleusercontent.com",
        'clientSecret' => "9II---------Kr",
        'refreshToken' => "1/-----------------M"
    ],
    'test' => [
        'developerToken' => "0HZ-----------R7g",
        'clientCustomerId' => "10--------8",
        'userAgent' => "Name",
        'clientId' => "92----------.apps.googleusercontent.com",
        'clientSecret' => "9II---------Kr",
        'refreshToken' => "1/-----------------M"
    ],
    'oAuth2' => [
        'authorizationUri' => 'https://accounts.google.com/o/oauth2/v2/auth',
        'redirectUri' => 'urn:ietf:wg:oauth:2.0:oob',
        'tokenCredentialUri' => 'https://www.googleapis.com/oauth2/v4/token',
        'scope' => 'https://www.googleapis.com/auth/adwords'
    ]
];

And this is my code to fetch the reports

$ads = new GoogleAds();
        $ads->env('test');
        $report = $ads->report();
        $obj = $ads->report()
            ->from('CRITERIA_PERFORMANCE_REPORT')
            ->where('Clicks > 10')
            ->where('Cost > 10')
            ->where('Impressions > 1')
            ->select('CampaignId','AdGroupId','AdGroupName','Id', 'Criteria', 'CriteriaType','Impressions', 'Clicks', 'Cost', 'UrlCustomParameters')
            ->getAsObj();
        print_r($ads);die;

I have got refresh token from oauth playground running this command php artisan googleads:token:generate gives error
Please provide a valid configuration for Laravel Google Ads

Edujugon commented 5 years ago

Hi @dee2499 ,

What package version do you have installed?

I'm trying to reproduce the error, but everything works as expected. I can run php artisan googleads:token:generate without any issue.

Please make sure then 'env' value in your google-ads.php config file is set correctly since those are the values that will be taken when creating the refresh token.