MCPcopy Create free account
hub / github.com/arctic-cli/interface / resolveCodexCredentials

Function resolveCodexCredentials

packages/arctic/src/provider/usage.ts:809–823  ·  view source on GitHub ↗
(auth: Auth.Info, providerID: string)

Source from the content-addressed store, hash-verified

807 const TOKEN_REFRESH_BUFFER_MS = 60 * 1000
808
809 async function resolveCodexCredentials(auth: Auth.Info, providerID: string): Promise<{ accessToken: string; accountId: string }> {
810 if (auth.type === "codex") {
811 const accessToken = await CodexClient.ensureValidTokenFor(providerID, auth)
812 const accountId = resolveAccountId(auth.accountId, auth.idToken ?? accessToken)
813 return { accessToken, accountId }
814 }
815
816 if (auth.type === "oauth") {
817 const accessToken = await ensureOauthAccessToken(auth, providerID)
818 const accountId = resolveAccountId(undefined, accessToken)
819 return { accessToken, accountId }
820 }
821
822 throw new Error("Codex authentication is required. Run `arctic auth codex` to connect your account.")
823 }
824
825 async function ensureOauthAccessToken(auth: Extract<Auth.Info, { type: "oauth" }>, providerID: string): Promise<string> {
826 let token = auth.access

Callers 1

fetchCodexUsageFunction · 0.85

Calls 2

resolveAccountIdFunction · 0.85
ensureOauthAccessTokenFunction · 0.85

Tested by

no test coverage detected