Why the token is expired even I had configured the refresh token?

810 views
Skip to first unread message

Xingguo Sun

unread,
Jan 20, 2020, 9:24:53 AM1/20/20
to AdWords API and Google Ads API Forum
Hi, 

I confronted this problem and do not know how to fix it. I do not need to update the token if I have configure the refresh token, right?

Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error: `POST https://oauth2.googleapis.com/token` resulted in a `400 Bad Request` response:
{
"error": "invalid_grant",
"error_description": "Token has been expired or revoked."
}

The code:

// Generate a refreshable OAuth2 credential for authentication.
$oAuth2Credential = (new OAuth2TokenBuilder())->fromFile()->build();

// Construct an API session configured from a properties file and the
// OAuth2 credentials above.
$session = (new AdWordsSessionBuilder())->fromFile()->withOAuth2Credential($oAuth2Credential)->build();
self::runExample(new AdWordsServices(), $session, self::AD_GROUP_ID);

Google Ads API Forum Advisor Prod

unread,
Jan 21, 2020, 3:49:54 PM1/21/20
to xingg...@deptagency.com, adwor...@googlegroups.com
Hi Xingguo,

Thank you for reaching out. Please provide your client customer ID and complete detailed request and response logs via reply privately to author so that I can further investigate the issue. If you're using AdWords API, you can find information on enabling logging here. If you're using Google Ads API, you can find it here.

Please make sure you have properly set up your config file and got your refresh token by following the instructions here.

Regards,
Mitchell
Google Ads API Team

ref:_00D1U1174p._5001USwqaM:ref
Reply all
Reply to author
Forward
0 new messages