MCPcopy Create free account
hub / github.com/Noumena-Network/code / getClaudeAIOAuthTokensAsync

Function getClaudeAIOAuthTokensAsync

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

Source from the content-addressed store, hash-verified

1485 * (which don't hit the keychain), and only uses async for storage reads.
1486 */
1487export async function getClaudeAIOAuthTokensAsync(): Promise<OAuthTokens | null> {
1488 if (isBareMode()) return null
1489
1490 // Env var and FD tokens are sync and don't hit the keychain
1491 if (
1492 process.env.NCODE_OAUTH_TOKEN ||
1493 process.env.CLAUDE_CODE_OAUTH_TOKEN ||
1494 getOAuthTokenFromFileDescriptor()
1495 ) {
1496 return getClaudeAIOAuthTokens()
1497 }
1498
1499 try {
1500 const secureStorage = getSecureStorage()
1501 const storageData = await secureStorage.readAsync()
1502 const oauthData = storageData?.claudeAiOauth
1503 if (!oauthData?.accessToken) {
1504 return null
1505 }
1506 return oauthData
1507 } catch (error) {
1508 logError(error)
1509 return null
1510 }
1511}
1512
1513// In-flight promise for deduplicating concurrent calls
1514let 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