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

Function getUsableClaudeAiAccessToken

src/utils/auth.ts:1834–1859  ·  view source on GitHub ↗
(options?: {
  requireProfileScope?: boolean
})

Source from the content-addressed store, hash-verified

1832}
1833
1834export function getUsableClaudeAiAccessToken(options?: {
1835 requireProfileScope?: boolean
1836}): string | null {
1837 if (!isAnthropicAuthEnabled()) {
1838 return null
1839 }
1840
1841 const oauthTokens = getClaudeAIOAuthTokens()
1842 if (!oauthTokens?.accessToken) {
1843 return null
1844 }
1845
1846 if (!shouldUseClaudeAIAuth(oauthTokens.scopes)) {
1847 return null
1848 }
1849
1850 if (options?.requireProfileScope && !hasProfileScope()) {
1851 return null
1852 }
1853
1854 if (isOAuthTokenExpired(oauthTokens.expiresAt)) {
1855 return null
1856 }
1857
1858 return oauthTokens.accessToken
1859}
1860
1861export function is1PApiCustomer(): boolean {
1862 // 1P API customers are users who are NOT:

Callers 1

getManagedOAuthStateFunction · 0.85

Calls 4

isAnthropicAuthEnabledFunction · 0.85
shouldUseClaudeAIAuthFunction · 0.85
hasProfileScopeFunction · 0.85
isOAuthTokenExpiredFunction · 0.85

Tested by

no test coverage detected