Invalid Grant

50 views
Skip to first unread message

Autoeurope Developer

unread,
Feb 24, 2017, 3:22:17 AM2/24/17
to AdWords API Forum

Hi All,

I have several scripts that run in cron jobs every day, (to update labels, download reports, set bidding options etc...). These have all been working fine for over a month, and today I started getting this message:

{ "error": "invalid_grant", "error_description": "Bad Request" } 

when trying to connect (with both my Test Account Token and my Main MCM Account token). I have Standard Access privileges, not sure if it's relevant.

Below is a simple script I use just to test the connection (which has also been working for over a month, until today). Nothing (really, not a single thing) has been changed on my side that could cause this error.


Any help is appreciated.

Thank you.


<?php
@session_start();
if(!isset($_SESSION['ae']['userId'])){
 echo
'Session has expired. please refresh your page and login again.';
 
exit();
}
$t
= microtime();
require_once
'../_adwordsAPI/init.php';
if(isset($_POST['customerID'])){
 $cID
= trim($_POST['customerID']);
}
try{
 $user
= new AdWordsUser('../_adwordsAPI/auth.ini');
 $user
->SetClientCustomerId($cID);
 
GetAccountHierarchyExample($user);
 $ms
= microtime() - $t;
 echo
'Connection Successful. Ping time = '.round(($ms*1000),3).'ms';
}catch(Exception $e){
  echo
"An error has occurred: " . $e->getMessage();
}


function GetAccountHierarchyExample(AdWordsUser $user){
 $managedCustomerService
= $user->GetService('ManagedCustomerService');
 $selector
= new Selector();
 $selector
->fields = array('CustomerId',  'Name');
 $graph
= $managedCustomerService->get($selector);
 
if(isset($graph->entries)){
 $cnt
= 0;
 
foreach ($graph->entries as $account) {
     $cnt
++;
 
}
 echo
'This Account has <b>'. ($cnt -1) . '</b> Clients<br><br>';
 
}else{
 echo
"No accounts were found.<br>";
 
}
}


exit();
?>

Nick

unread,
Feb 24, 2017, 5:38:09 AM2/24/17
to AdWords API Forum
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages