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

Function getOauthProfileFromApiKey

src/services/oauth/getOauthProfile.ts:7–35  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5import { getGlobalConfig } from 'src/utils/config.js'
6import { logError } from 'src/utils/log.js'
7export async function getOauthProfileFromApiKey(): Promise<
8 OAuthProfileResponse | undefined
9> {
10 // Assumes interactive session
11 const config = getGlobalConfig()
12 const accountUuid = config.oauthAccount?.accountUuid
13 const apiKey = getAnthropicApiKey()
14
15 // Need both account UUID and API key to check
16 if (!accountUuid || !apiKey) {
17 return
18 }
19 const endpoint = `${getOauthConfig().BASE_API_URL}/api/claude_cli_profile`
20 try {
21 const response = await axios.get<OAuthProfileResponse>(endpoint, {
22 headers: {
23 'x-api-key': apiKey,
24 'anthropic-beta': OAUTH_BETA_HEADER,
25 },
26 params: {
27 account_uuid: accountUuid,
28 },
29 timeout: 10000,
30 })
31 return response.data
32 } catch (error) {
33 logError(error as Error)
34 }
35}
36
37export async function getOauthProfileFromOauthToken(
38 accessToken: string,

Callers 1

Calls 4

getGlobalConfigFunction · 0.85
getAnthropicApiKeyFunction · 0.85
getOauthConfigFunction · 0.85
logErrorFunction · 0.50

Tested by

no test coverage detected