MCPcopy
hub / github.com/codeaashu/claude-code / getClaudeAIOAuthTokensAsync

Function getClaudeAIOAuthTokensAsync

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

Source from the content-addressed store, hash-verified

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