This repository was archived by the owner on May 15, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ import { GlobalFileNames } from "../../shared/globalFileNames"
3636import { UnauthorizedError } from "@modelcontextprotocol/sdk/client/auth.js"
3737
3838import { fileExistsAtPath } from "../../utils/fs"
39+ import { TOKEN_EXPIRY_BUFFER_MS } from "./constants"
3940import { SecretStorageService } from "./SecretStorageService"
4041import { McpOAuthClientProvider } from "./McpOAuthClientProvider"
4142import { arePathsEqual , getWorkspacePath } from "../../utils/path"
@@ -1053,8 +1054,6 @@ export class McpHub {
10531054 return
10541055 }
10551056
1056- const TOKEN_EXPIRY_BUFFER_MS = 5 * 60 * 1000
1057-
10581057 // Check if another window already saved valid tokens
10591058 const existing = await this . secretStorage . getOAuthData ( serverUrl )
10601059 if ( existing && Date . now ( ) < existing . expires_at - TOKEN_EXPIRY_BUFFER_MS ) {
@@ -1163,8 +1162,6 @@ export class McpHub {
11631162 this . _oauthWatchers . delete ( watcherKey )
11641163 }
11651164
1166- const TOKEN_EXPIRY_BUFFER_MS = 5 * 60 * 1000
1167-
11681165 // Called when SecretStorage fires onDidChange for this server's key.
11691166 // Runs in all VS Code windows the instant tokens are saved — no polling delay.
11701167 const onTokensChanged = async ( ) => {
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import type {
99 OAuthTokens ,
1010} from "@modelcontextprotocol/sdk/shared/auth.js"
1111
12+ import { TOKEN_EXPIRY_BUFFER_MS } from "./constants"
1213import { SecretStorageService } from "./SecretStorageService"
1314import { startCallbackServer , stopCallbackServer } from "./utils/callbackServer"
1415import { fetchOAuthAuthServerMetadata } from "./utils/oauth"
@@ -265,7 +266,7 @@ export class McpOAuthClientProvider implements OAuthClientProvider {
265266 if ( ! data ) return undefined
266267
267268 // If the access token is still valid (with 5m buffer), return it.
268- if ( Date . now ( ) < data . expires_at - 5 * 60 * 1000 ) {
269+ if ( Date . now ( ) < data . expires_at - TOKEN_EXPIRY_BUFFER_MS ) {
269270 return data . tokens
270271 }
271272
Original file line number Diff line number Diff line change 1+ export const TOKEN_EXPIRY_BUFFER_MS = 5 * 60 * 1000 // 5 minutes
You can’t perform that action at this time.
0 commit comments