fix(grok-cli): surface expiresAt so proactive token refresh fires (#2546)

This commit is contained in:
Ella CEO
2026-07-16 12:00:14 +07:00
parent a6a41dfb3c
commit 7dfb346667
2 changed files with 67 additions and 0 deletions
+10
View File
@@ -350,10 +350,20 @@ const PROVIDERS = {
.join(" ")
.trim() || null;
const expiresAt = tokens.expires_in
? new Date(Date.now() + tokens.expires_in * 1000).toISOString()
: null;
return {
accessToken: tokens.access_token,
refreshToken: tokens.refresh_token || null,
expiresIn: tokens.expires_in,
// Surface an absolute expiry so the proactive refresh path
// (shouldRefreshCredentials / checkAndRefreshToken) can refresh the
// xAI token before it silently expires ~40-45 min after login.
// Without this, only the reactive 401 path in chatCore would refresh,
// causing intermittent "token expired" failures for Grok CLI.
expiresAt,
scope: tokens.scope,
// Top-level for dashboard connection cards
email: email || undefined,