Answer the question
In order to leave comments, you need to log in
Google Calendar OAuth 2.0. For what reason can a refresh token fail?
Set up integration with google calendar. Used the library for php google/apiclient. The standard code is
function getClient()
{
$client = new Google_Client();
$client->setApplicationName(APP_NAME);
$client->setScopes('https://www.googleapis.com/auth/calendar');
$client->setClientId(CLIENT_ID);
$client->setClientSecret(CLIENT_SECRET);
$client->setAccessType('offline');
$client->setRedirectUri('RETURN_URL');
$client->setApprovalPrompt('force');
return $client;
}
// $refresh_token - ранее полученный токен
$client = getClient();
$client->refreshToken($refresh_token);
$service = new \Google_Service_Calendar($client);
// далее работаю с календарем
echo getClient()->createAuthUrl();
// далее в RETURN_URL разбираю ответ и сохраняю $refresh_token
Answer the question
In order to leave comments, you need to log in
https://developers.google.com/identity/protocols/O... here is the answer.
The refresh_token has both an expiration time and the number of times it can generate an access_token (limit 25). In the code, the access_token is updated every time, in theory, after 25 api requests, the refresh_token will become invalid. I made more requests, everything worked fine.
It turns out that the logic should be as follows:
Correct me if I'm wrong.
Now the question is different: the documentation says 25 for the refresh_token usage limit, I did more, why does it continue to work?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question