MCPcopy Index your code
hub / github.com/arctic-cli/interface / requestUserCode

Function requestUserCode

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

Source from the content-addressed store, hash-verified

191 }
192
193 export async function requestUserCode(): Promise<DeviceCodeResponse> {
194 const response = await fetch(`${issuerPath("/api/accounts/deviceauth/usercode")}`, {
195 method: "POST",
196 headers: {
197 "Content-Type": "application/json",
198 },
199 body: JSON.stringify({
200 client_id: Config.clientId,
201 }),
202 })
203
204 if (!response.ok) {
205 const text = await response.text()
206 throw new Error(`Failed to request user code: ${response.status} - ${text}`)
207 }
208
209 const body = await response.json()
210 const deviceAuthId = body.device_auth_id
211 const userCode = body.user_code
212 if (!deviceAuthId || !userCode) {
213 throw new Error("Received invalid response when requesting device code")
214 }
215
216 return {
217 deviceAuthId,
218 userCode,
219 interval: parseInterval(body.interval),
220 verificationUri: DEVICE_LOGIN_URL,
221 }
222 }
223
224 export function printDeviceCodePrompt(code: string, verificationUrl = DEVICE_LOGIN_URL): void {
225 console.log(`

Callers 1

loginFunction · 0.85

Calls 5

issuerPathFunction · 0.85
parseIntervalFunction · 0.85
textMethod · 0.65
jsonMethod · 0.65
fetchFunction · 0.50

Tested by

no test coverage detected