I\'m working off an example trying to learn how to use the google api to change events on a calendar. The server is the user which will update the calendar based off of inf
Check if the token has a refresh-token (if you request offline access, the refresh-token will be sent with the access token the first time).
Something like this
$token = $client->getAccessToken();
$authObj = json_decode($token);
if(isset($authObj->refresh_token)) {
save_refresh_token($authObj->refresh_token);
}
Where save_refresh_token saves your refresh-token somewhere (db).
Then you can check if token as expired by:
$client->isAccessTokenExpired()
If it is, you can update it with:
$client->refreshToken($your_saved_refresh_token);
And then set your new access token to the session:
$_SESSION['access_token'] = $client->getAccessToken();