fix(astrolabe): add issued_at to on-demand token refresh

Fixes missing issued_at parameter when storing tokens refreshed via
getAccessToken() callback, ensuring accurate token lifetime calculation
for the background refresh job.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Chris Coutinho
2026-01-27 11:25:43 +01:00
co-authored by Claude Opus 4.5
parent 28219e00e7
commit c46f9eb212
2 changed files with 12 additions and 11 deletions
+12 -4
View File
@@ -217,14 +217,22 @@ class McpTokenStorage {
if ($newTokenData && isset($newTokenData['access_token'])) {
// Store refreshed token
// Use new refresh token if provided (rotation), otherwise keep old one
$now = time();
/** @var string $accessToken */
$accessToken = $newTokenData['access_token'];
/** @var string $refreshToken */
$refreshToken = $newTokenData['refresh_token'] ?? $token['refresh_token'];
$expiresIn = (int)($newTokenData['expires_in'] ?? 3600);
$this->storeUserToken(
$userId,
$newTokenData['access_token'],
$newTokenData['refresh_token'] ?? $token['refresh_token'],
time() + ($newTokenData['expires_in'] ?? 3600)
$accessToken,
$refreshToken,
$now + $expiresIn,
$now // issued_at for accurate lifetime calculation
);
return $newTokenData['access_token'];
return $accessToken;
}
} catch (\Exception $e) {
$this->logger->error("Failed to refresh token for user $userId", [