2
I’m trying to get a new one access_token
after it has expired.
I already keep in the bank the information I receive as a return on the customer’s first access:
{"access_token":"TOKEN","refresh_token":"TOKEN","token_type":"Bearer","expires_in":3600,"created":1320790426}
After this token expires I need to request a new one, I’m doing it this way:
$client = new Google_Client();
$client->setApplicationName(APPLICATION_NAME);
$client->setScopes(SCOPES);
$client->setAuthConfigFile(CLIENT_SECRET_PATH);
$client->setAccessType('offline');
$token['access_token'] = $db->dados[0]['access_token'];
$token['refresh_token'] = $db->dados[0]['refresh_token'];
$token['token_type'] = $db->dados[0]['token_type'];
$token['expires_in'] = $db->dados[0]['expires_in'];
$token['created'] = $db->dados[0]['created'];
$client->setAccessToken(json_encode($token));
if ($client->isAccessTokenExpired()) {
echo "Expirado !";
$client->refreshToken($client->getRefreshToken());
} else {
echo "Valendo !";
}
The problem is that I always get this error message:
Error Refreshing the Oauth2 token, message: '{ "error" : "invalid_grant" }
As far as I know the Google Search Apis have been archived, so I don’t know if they still work.
– Roberto Araujo
In this case I am trying to access the Gmail API: https://developers.google.com/gmail/api/quickstart/php
– CESD
And if this Google link works, https://developers.google.com/oauthplayground/ Ma mine is giving error...
– CESD