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

Function login

packages/arctic/src/auth/codex.ts:307–325  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

305 }
306
307 export async function login(): Promise<void> {
308 const userCodeResponse = await requestUserCode()
309 printDeviceCodePrompt(userCodeResponse.userCode, userCodeResponse.verificationUri)
310
311 const tokens = await pollForToken(userCodeResponse.deviceAuthId, userCodeResponse.userCode, userCodeResponse.interval)
312 const idTokenInfo = parseIdToken(tokens.id_token)
313 const expiresIn = tokens.expires_in ?? 3600
314
315 await Auth.set("codex", {
316 type: "codex",
317 accessToken: tokens.access_token,
318 refreshToken: tokens.refresh_token,
319 idToken: tokens.id_token,
320 accountId: idTokenInfo?.chatgpt_account_id,
321 expiresAt: Date.now() + expiresIn * 1000,
322 email: idTokenInfo?.email,
323 planType: idTokenInfo?.chatgpt_plan_type,
324 })
325 }
326
327 export async function refresh(refreshToken: string): Promise<TokenResponse> {
328 const url = `${Config.issuerBaseUrl}/oauth/token`

Callers

nothing calls this directly

Calls 5

requestUserCodeFunction · 0.85
printDeviceCodePromptFunction · 0.85
parseIdTokenFunction · 0.85
pollForTokenFunction · 0.70
setMethod · 0.45

Tested by

no test coverage detected