400 Bad Request

3,121 views
Skip to first unread message

SUBIN P VASU

unread,
Mar 2, 2018, 12:45:12 PM3/2/18
to AdWords API Forum

An uncaught Exception was encountered

Type: GuzzleHttp\Exception\ClientException

Message: Client error: `POST https://www.googleapis.com/oauth2/v4/token` resulted in a `400 Bad Request` response: { "error": "invalid_grant", "error_description": "Code was already redeemed." }

Filename: C:\wamp\www\FeedWize\application\libraries\external\vendor\guzzlehttp\guzzle\src\Exception\RequestException.php

Line Number: 113


Backtrace:

File: C:\wamp\www\FeedWize\application\libraries\external\vendor\guzzlehttp\guzzle\src\Middleware.php
Line: 65
Function: create

File: C:\wamp\www\FeedWize\application\libraries\external\vendor\guzzlehttp\promises\src\Promise.php
Line: 203
Function: GuzzleHttp\{closure}

File: C:\wamp\www\FeedWize\application\libraries\external\vendor\guzzlehttp\promises\src\Promise.php
Line: 156
Function: callHandler

File: C:\wamp\www\FeedWize\application\libraries\external\vendor\guzzlehttp\promises\src\TaskQueue.php
Line: 47
Function: GuzzleHttp\Promise\{closure}

File: C:\wamp\www\FeedWize\application\libraries\external\vendor\guzzlehttp\promises\src\Promise.php
Line: 246
Function: run

File: C:\wamp\www\FeedWize\application\libraries\external\vendor\guzzlehttp\promises\src\Promise.php
Line: 223
Function: invokeWaitFn

File: C:\wamp\www\FeedWize\application\libraries\external\vendor\guzzlehttp\promises\src\Promise.php
Line: 267
Function: waitIfPending

File: C:\wamp\www\FeedWize\application\libraries\external\vendor\guzzlehttp\promises\src\Promise.php
Line: 225
Function: invokeWaitList

File: C:\wamp\www\FeedWize\application\libraries\external\vendor\guzzlehttp\promises\src\Promise.php
Line: 62
Function: waitIfPending

File: C:\wamp\www\FeedWize\application\libraries\external\vendor\guzzlehttp\guzzle\src\Client.php
Line: 106
Function: wait

File: C:\wamp\www\FeedWize\application\libraries\external\vendor\google\auth\src\HttpHandler\Guzzle6HttpHandler.php
Line: 34
Function: send

File: C:\wamp\www\FeedWize\application\libraries\external\vendor\google\auth\src\OAuth2.php
Line: 492
Function: __invoke

File: C:\wamp\www\FeedWize\application\libraries\AccountProspect.php
Line: 45
Function: fetchAuthToken

File: C:\wamp\www\FeedWize\application\controllers\FeedController.php
Line: 190
Function: __construct

File: C:\wamp\www\FeedWize\index.php
Line: 315
Function: require_once


I think, I have almost there, Since i got the credentials by trying the code directly.

Please help me.

Milind Sankeshware (AdWords API Team)

unread,
Mar 2, 2018, 4:20:21 PM3/2/18
to AdWords API Forum
Hi Subin,

The "invalid_grant" error usually indicates that the access or refresh token being passed in your request is incorrect or invalid. 

To verify that your credentials are correct, you could also try the CURL request provided below and see if you are able to generate the access tokens? If the credentials are correct, you should get an access token for the below request.
curl https://www.googleapis.com/oauth2/v4/token \
-d refresh_token=your-refresh_token \
-d client_id=your-client-id \
-d client_secret=your-client-secret \
-d grant_type=refresh_token

If your credentials are incorrect and still facing an issues then could you generate a new refresh token with the help of this guide and retry your request? Let me know if the issue persists.

Thanks,
Milind, AdWords API Team.
Reply all
Reply to author
Forward
0 new messages