Issues With Making my First Call

467 views
Skip to first unread message

Eliot Shiner

unread,
Jun 16, 2017, 10:49:29 AM6/16/17
to AdWords API Forum
Hi,

I'm using PHP and followed the step by step guide, but am getting the following error message when trying to make my first call using the GetCampaigns.php script on a test account i've set up.

C:\xampp\htdocs\googleads-php-lib-master>php GetCampaigns.php
PHP Fatal error:  Uncaught exception 'GuzzleHttp\Exception\ClientException' with
 message 'Client error: `POST https://www.googleapis.com/oauth2/v4/token` result
ed in a `400 Bad Request` response:
{
 "error": "invalid_grant",
 "error_description": "Bad Request"
}

' in C:\xampp\htdocs\googleads-php-lib-master\vendor\guzzlehttp\guzzle\src\Excep
tion\RequestException.php:111
Stack trace:
#0 C:\xampp\htdocs\googleads-php-lib-master\vendor\guzzlehttp\guzzle\src\Middlew
are.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr
7\Request), Object(GuzzleHttp\Psr7\Response))
#1 C:\xampp\htdocs\googleads-php-lib-master\vendor\guzzlehttp\promises\src\Promi
se.php(203): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\
Response))
#2 C:\xampp\htdocs\googleads-php-lib-master\vendor\guzzlehttp\promises\src\Promi
se.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\R
esponse), Array)
#3 C:\xampp\htdocs\googleads-php-lib-master\vendor\guzzlehttp\promises\src\TaskQ
ueue.php(47): GuzzleH in C:\xampp\htdocs\googleads-php-lib-master\vendor\guzzleh
ttp\guzzle\src\Exception\RequestException.php on line 111

Fatal error: Uncaught exception 'GuzzleHttp\Exception\ClientException' with mess
age 'Client error: `POST https://www.googleapis.com/oauth2/v4/token` resulted in
 a `400 Bad Request` response:
{
 "error": "invalid_grant",
 "error_description": "Bad Request"
}

' in C:\xampp\htdocs\googleads-php-lib-master\vendor\guzzlehttp\guzzle\src\Excep
tion\RequestException.php:111
Stack trace:
#0 C:\xampp\htdocs\googleads-php-lib-master\vendor\guzzlehttp\guzzle\src\Middlew
are.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr
7\Request), Object(GuzzleHttp\Psr7\Response))
#1 C:\xampp\htdocs\googleads-php-lib-master\vendor\guzzlehttp\promises\src\Promi
se.php(203): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\
Response))
#2 C:\xampp\htdocs\googleads-php-lib-master\vendor\guzzlehttp\promises\src\Promi
se.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\R
esponse), Array)
#3 C:\xampp\htdocs\googleads-php-lib-master\vendor\guzzlehttp\promises\src\TaskQ
ueue.php(47): GuzzleH in C:\xampp\htdocs\googleads-php-lib-master\vendor\guzzleh
ttp\guzzle\src\Exception\RequestException.php on line 111

C:\xampp\htdocs\googleads-php-lib-master>


Any ideas?


Thanks!

Shwetha Vastrad (AdWords API Team)

unread,
Jun 16, 2017, 1:31:38 PM6/16/17
to AdWords API Forum
Hi Eliot,

Could you tell me the type of OAuth flow used in your application? This error generally occurs if the access/refresh token passed in the request is incorrect/invalid. To verify, you can obtain the access token being used for the request, then pass that through this tokeninfo endpoint to retrieve the token details. Could you try generating a new refresh token and retry the request?

Thanks,
Shwetha, AdWords API Team.

Eliot Shiner

unread,
Jun 20, 2017, 11:08:25 AM6/20/17
to AdWords API Forum
I'm using 'Installed Application' and trying to connect to the test account at CID level within my Test account MCC. I'll try getting a new refresh token now.

Thanks,

Eliot.
Reply all
Reply to author
Forward
0 new messages