MCPcopy Index your code
hub / github.com/codeaashu/claude-code / saveTokens

Method saveTokens

src/services/mcp/auth.ts:1704–1731  ·  view source on GitHub ↗
(tokens: OAuthTokens)

Source from the content-addressed store, hash-verified

1702 }
1703
1704 async saveTokens(tokens: OAuthTokens): Promise<void> {
1705 this._pendingStepUpScope = undefined
1706 const storage = getSecureStorage()
1707 const existingData = storage.read() || {}
1708 const serverKey = getServerKey(this.serverName, this.serverConfig)
1709
1710 logMCPDebug(this.serverName, `Saving tokens`)
1711 logMCPDebug(this.serverName, `Token expires in: ${tokens.expires_in}`)
1712 logMCPDebug(this.serverName, `Has refresh token: ${!!tokens.refresh_token}`)
1713
1714 const updatedData: SecureStorageData = {
1715 ...existingData,
1716 mcpOAuth: {
1717 ...existingData.mcpOAuth,
1718 [serverKey]: {
1719 ...existingData.mcpOAuth?.[serverKey],
1720 serverName: this.serverName,
1721 serverUrl: this.serverConfig.url,
1722 accessToken: tokens.access_token,
1723 refreshToken: tokens.refresh_token,
1724 expiresAt: Date.now() + (tokens.expires_in || 3600) * 1000,
1725 scope: tokens.scope,
1726 },
1727 },
1728 }
1729
1730 storage.update(updatedData)
1731 }
1732
1733 /**
1734 * XAA silent refresh: cached id_token → Layer-2 exchange → new access_token.

Callers 1

_doRefreshMethod · 0.95

Calls 5

getSecureStorageFunction · 0.85
getServerKeyFunction · 0.85
logMCPDebugFunction · 0.85
readMethod · 0.65
updateMethod · 0.65

Tested by

no test coverage detected