MCPcopy Create free account
hub / github.com/claude-code-best/claude-code / getClaudeAIOAuthTokensAsync

Function getClaudeAIOAuthTokensAsync

src/utils/auth.ts:1395–1418  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1393 * (which don't hit the keychain), and only uses async for storage reads.
1394 */
1395export async function getClaudeAIOAuthTokensAsync(): Promise<OAuthTokens | null> {
1396 if (isBareMode()) return null
1397
1398 // Env var and FD tokens are sync and don't hit the keychain
1399 if (
1400 process.env.CLAUDE_CODE_OAUTH_TOKEN ||
1401 getOAuthTokenFromFileDescriptor()
1402 ) {
1403 return getClaudeAIOAuthTokens()
1404 }
1405
1406 try {
1407 const secureStorage = getSecureStorage()
1408 const storageData = await secureStorage.readAsync()
1409 const oauthData = storageData?.claudeAiOauth
1410 if (!oauthData?.accessToken) {
1411 return null
1412 }
1413 return oauthData
1414 } catch (error) {
1415 logError(error)
1416 return null
1417 }
1418}
1419
1420// In-flight promise for deduplicating concurrent calls
1421let pendingRefreshCheck: Promise<boolean> | null = null

Callers 2

handleOAuth401ErrorImplFunction · 0.85

Calls 4

isBareModeFunction · 0.85
getSecureStorageFunction · 0.85
logErrorFunction · 0.70

Tested by

no test coverage detected