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

Function getAccountInformation

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

Source from the content-addressed store, hash-verified

1875}
1876
1877export function getAccountInformation() {
1878 const apiProvider = getAPIProvider()
1879 // Only provide account info for first-party Anthropic API
1880 if (apiProvider !== 'firstParty') {
1881 return undefined
1882 }
1883 const { source: authTokenSource } = getAuthTokenSource()
1884 const accountInfo: UserAccountInfo = {}
1885 if (
1886 authTokenSource === 'CLAUDE_CODE_OAUTH_TOKEN' ||
1887 authTokenSource === 'CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR'
1888 ) {
1889 accountInfo.tokenSource = authTokenSource
1890 } else if (isClaudeAISubscriber()) {
1891 accountInfo.subscription = getSubscriptionName()
1892 } else {
1893 accountInfo.tokenSource = authTokenSource
1894 }
1895 const { key: apiKey, source: apiKeySource } = getAnthropicApiKeyWithSource()
1896 if (apiKey) {
1897 accountInfo.apiKeySource = apiKeySource
1898 }
1899
1900 // 如果我们依赖外部 API 密钥或认证令牌,则不知道组织
1901 if (
1902 authTokenSource === 'claude.ai' ||
1903 apiKeySource === '/login managed key'
1904 ) {
1905 // 从 OAuth 账户信息获取组织名称
1906 const orgName = getOauthAccountInfo()?.organizationName
1907 if (orgName) {
1908 accountInfo.organization = orgName
1909 }
1910 }
1911 const email = getOauthAccountInfo()?.emailAddress
1912 if (
1913 (authTokenSource === 'claude.ai' ||
1914 apiKeySource === '/login managed key') &&
1915 email
1916 ) {
1917 accountInfo.email = email
1918 }
1919 return accountInfo
1920}
1921
1922/**
1923 * Result of org validation — either success or a descriptive error.

Callers 3

buildAccountPropertiesFunction · 0.85
runHeadlessStreamingFunction · 0.85
handleInitializeRequestFunction · 0.85

Calls 6

getAPIProviderFunction · 0.85
getAuthTokenSourceFunction · 0.85
getSubscriptionNameFunction · 0.85
isClaudeAISubscriberFunction · 0.70
getOauthAccountInfoFunction · 0.70

Tested by

no test coverage detected