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

Function getAccountInformation

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

Source from the content-addressed store, hash-verified

1861}
1862
1863export function getAccountInformation() {
1864 const apiProvider = getAPIProvider()
1865 // Only provide account info for first-party Anthropic API
1866 if (apiProvider !== 'firstParty') {
1867 return undefined
1868 }
1869 const { source: authTokenSource } = getAuthTokenSource()
1870 const accountInfo: UserAccountInfo = {}
1871 if (
1872 authTokenSource === 'CLAUDE_CODE_OAUTH_TOKEN' ||
1873 authTokenSource === 'CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR'
1874 ) {
1875 accountInfo.tokenSource = authTokenSource
1876 } else if (isClaudeAISubscriber()) {
1877 accountInfo.subscription = getSubscriptionName()
1878 } else {
1879 accountInfo.tokenSource = authTokenSource
1880 }
1881 const { key: apiKey, source: apiKeySource } = getAnthropicApiKeyWithSource()
1882 if (apiKey) {
1883 accountInfo.apiKeySource = apiKeySource
1884 }
1885
1886 // We don't know the organization if we're relying on an external API key or auth token
1887 if (
1888 authTokenSource === 'claude.ai' ||
1889 apiKeySource === '/login managed key'
1890 ) {
1891 // Get organization name from OAuth account info
1892 const orgName = getOauthAccountInfo()?.organizationName
1893 if (orgName) {
1894 accountInfo.organization = orgName
1895 }
1896 }
1897 const email = getOauthAccountInfo()?.emailAddress
1898 if (
1899 (authTokenSource === 'claude.ai' ||
1900 apiKeySource === '/login managed key') &&
1901 email
1902 ) {
1903 accountInfo.email = email
1904 }
1905 return accountInfo
1906}
1907
1908/**
1909 * 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