axios+telemetry cleanup
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import axios from 'axios'
|
||||
import { getOauthConfig, OAUTH_BETA_HEADER } from 'src/constants/oauth.js'
|
||||
import type { OAuthProfileResponse } from 'src/services/oauth/types.js'
|
||||
import { getAnthropicApiKey } from 'src/utils/auth.js'
|
||||
import { getGlobalConfig } from 'src/utils/config.js'
|
||||
import { nativeRequest } from 'src/utils/http.js'
|
||||
import { logError } from 'src/utils/log.js'
|
||||
export async function getOauthProfileFromApiKey(): Promise<
|
||||
OAuthProfileResponse | undefined
|
||||
@@ -16,19 +16,16 @@ export async function getOauthProfileFromApiKey(): Promise<
|
||||
if (!accountUuid || !apiKey) {
|
||||
return
|
||||
}
|
||||
const endpoint = `${getOauthConfig().BASE_API_URL}/api/claude_cli_profile`
|
||||
const endpoint = `${getOauthConfig().BASE_API_URL}/api/claude_cli_profile?account_uuid=${encodeURIComponent(accountUuid)}`
|
||||
try {
|
||||
const response = await axios.get<OAuthProfileResponse>(endpoint, {
|
||||
const { data } = await nativeRequest<OAuthProfileResponse>(endpoint, {
|
||||
headers: {
|
||||
'x-api-key': apiKey,
|
||||
'anthropic-beta': OAUTH_BETA_HEADER,
|
||||
},
|
||||
params: {
|
||||
account_uuid: accountUuid,
|
||||
},
|
||||
timeout: 10000,
|
||||
})
|
||||
return response.data
|
||||
return data
|
||||
} catch (error) {
|
||||
logError(error as Error)
|
||||
}
|
||||
@@ -39,14 +36,14 @@ export async function getOauthProfileFromOauthToken(
|
||||
): Promise<OAuthProfileResponse | undefined> {
|
||||
const endpoint = `${getOauthConfig().BASE_API_URL}/api/oauth/profile`
|
||||
try {
|
||||
const response = await axios.get<OAuthProfileResponse>(endpoint, {
|
||||
const { data } = await nativeRequest<OAuthProfileResponse>(endpoint, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
timeout: 10000,
|
||||
})
|
||||
return response.data
|
||||
return data
|
||||
} catch (error) {
|
||||
logError(error as Error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user