handles Google refresh token

This commit is contained in:
Santiago Lema 2025-05-21 02:36:26 +00:00
parent b5adf7dbd0
commit dee2522676
2 changed files with 16 additions and 5 deletions

View file

@ -109,12 +109,13 @@ while (true) {
]);
if (isset($tokenResponse['access_token'])) {
$token = $tokenResponse;
echo "Saving token.json\n";
file_put_contents(__DIR__ . '/_credentials/token.json', json_encode($token));
break;
$tokenResponse['expires_at'] = time() + $tokenResponse['expires_in'];
file_put_contents(__DIR__ . '/_credentials/token.json', json_encode($tokenResponse));
echo "✅ Token saved with expiration.\n";
break;
}
if (isset($tokenResponse['error']) && $tokenResponse['error'] !== 'authorization_pending') {
die("Auth error: " . $tokenResponse['error'] . "\n");
}