Issue with re-authorization using refresh token

42 views
Skip to first unread message

teste...@gmail.com

unread,
Jul 14, 2016, 3:26:54 AM7/14/16
to AdWords API Forum
Hello guys,

I have been trying to get a users data who previously authorized the application, but it keeps returning 

Fatal error: Uncaught ReflectionException: Property does not exist in

The property does indeed exist as it is my test account I am running it against.

ViewID for test account = 7827124895

When I run the script it does not populate my log files at all.

My code below.

    $user = new AdWordsUser();
    $user->setUserAgent($userAgent);
    $user->SetDeveloperToken($devToken);

    $OAuthDetails = array(
        "client_id" => $clientId,
        "client_secret" => $clientSecret,
        "access_token" => $dbUser["access_token"],
        "access_type" => "offline",
        "refresh_token" => $dbUser["refresh_token"]
    );

    $user->SetOAuth2Info($OAuthDetails);
    $oauthHandler = $user->GetDefaultOAuth2Handler();
    $user->LogAll();
    
    $newToken = $oauthHandler->GetOrRefreshAccessToken($OAuthDetails);
    $user->SetOAuth2Info($newToken);

    $accounts = explode(',', $dbUser['viewID']);

    foreach($accounts as $account) {
        $user->SetClientCustomerId($account);
        print_r($account);
        getAndSaveAccountData($db, $dbUser['userID'], $user, $account);
    }

function getAndSaveAccountData($db, $userID, $user, $id) {
    $options = array('version' => 'v201605');
    $options['includeZeroImpressions'] = true;
    $options['skipColumnHeader'] = true;
    $options['skipReportHeader'] = true;
    $options['skipReportSummary'] = true;

    $today = date("Ymd");
    $yesterday = date('Ymd', strtotime('-1 days'));

    $reportQuery = "SELECT Date, Cost, Conversions, CostPerConversion, ConversionRate FROM ACCOUNT_PERFORMANCE_REPORT DURING $today, $yesterday";

    $reportUtils = new ReportUtils();
    $data = $reportUtils->DownloadReportWithAwql($reportQuery, null, $user, "CSV", $options);
    $rows = [];
    print_r("data = ");
    print_r($rows);


teste...@gmail.com

unread,
Jul 14, 2016, 3:28:39 AM7/14/16
to AdWords API Forum
Another error I get with the previous error
Notice: Undefined index: type in <path to adwords lib>\lib\Google\Api\Ads\AdWords\Util\XmlDeserializer.php on line 136


Anthony Madrigal

unread,
Jul 14, 2016, 6:20:07 PM7/14/16
to AdWords API Forum
Hi, 

Are your credentials in your auth.ini file set up properly? What message do you get when you try to generate a refresh token?

Thanks,
Anthony
AdWords API Team

teste...@gmail.com

unread,
Jul 14, 2016, 10:16:33 PM7/14/16
to AdWords API Forum
I am setting the details manually in the code, this works when I intially authorize and pull the data, but when I retry with refresh token it doesn't.

Anthony Madrigal

unread,
Jul 15, 2016, 11:31:43 AM7/15/16
to AdWords API Forum
Hi,

Could you please send me your credentials and the manager Id you used to create them via reply privately to author?
Reply all
Reply to author
Forward
0 new messages