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

Function handleAlibabaLogin

packages/arctic/src/cli/cmd/auth.ts:364–413  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

362}
363
364async function handleAlibabaLogin() {
365 const check = await checkExistingConnection("alibaba")
366 if (!check.proceed) {
367 prompts.outro("Cancelled")
368 return
369 }
370
371 prompts.log.info("Authorize Alibaba (Qwen Code) with your Qwen account via device login.")
372
373 const { ArcticQwenAuth } = await import("../../auth/qwen-oauth")
374 const plugin = await ArcticQwenAuth({} as any)
375
376 if (!plugin.auth) {
377 throw new Error("Qwen auth plugin failed to initialize")
378 }
379
380 const oauthMethod = plugin.auth.methods.find((m) => m.type === "oauth")
381 if (!oauthMethod || !oauthMethod.authorize) {
382 throw new Error("Qwen OAuth method not found")
383 }
384
385 const authorize = await oauthMethod.authorize()
386
387 if (authorize.instructions) {
388 prompts.log.info(authorize.instructions)
389 }
390
391 if (authorize.method === "auto" && authorize.callback) {
392 const spinner = prompts.spinner()
393 spinner.start("Waiting for authorization...")
394 const result = await authorize.callback()
395 if (result.type === "failed") {
396 spinner.stop("Failed to authorize", 1)
397 }
398 if (result.type === "success") {
399 spinner.stop("Login successful")
400
401 const alibabaAuth = await Auth.get("alibaba")
402 if (alibabaAuth) {
403 const authKey = check.connectionName ? Auth.formatKey("alibaba", check.connectionName) : "alibaba"
404 if (authKey !== "alibaba") {
405 await Auth.set(authKey, alibabaAuth)
406 await Auth.remove("alibaba")
407 }
408 }
409 }
410 }
411
412 prompts.outro("Done")
413}
414
415export const AuthCommand = cmd({
416 command: "auth",

Callers 1

fnFunction · 0.85

Calls 9

ArcticQwenAuthFunction · 0.85
stopMethod · 0.80
checkExistingConnectionFunction · 0.70
authorizeMethod · 0.45
startMethod · 0.45
callbackMethod · 0.45
getMethod · 0.45
setMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected