jackwener/OpenCLI · error · AuthRequiredError

请在浏览器里用千问 APP 扫码登录 qianwen.com 后再重试。

Error message

请在浏览器里用千问 APP 扫码登录 qianwen.com 后再重试。

What it means

AuthRequiredError thrown by `qwen send` when the prompt cannot be delivered because a login gate is present on qianwen.com. `send` only dispatches the message, so this is the earliest and most direct auth failure path: sendMessage fails and hasLoginGate(page) confirms an unauthenticated session, producing the QR-scan instruction via authRequired().

Source

Thrown at clis/qwen/send.js:50

    func: async (page, kwargs) => {
        const prompt = String(kwargs.prompt || '').trim();
        if (!prompt) throw new ArgumentError('prompt is required');
        const startFresh = normalizeBooleanFlag(kwargs.new, false);
        const useThink = normalizeBooleanFlag(kwargs.think, false);
        const useResearch = normalizeBooleanFlag(kwargs.research, false);

        await ensureOnQianwen(page);
        await dismissLoginModal(page);
        if (startFresh) {
            await startNewChat(page);
            await dismissLoginModal(page);
        }
        if (useThink) await setFeatureToggle(page, 'think', true);
        if (useResearch) await setFeatureToggle(page, 'research', true);

        const send = await sendMessage(page, prompt);
        if (!send?.ok) {
            if (await hasLoginGate(page)) throw authRequired();
            throw new CommandExecutionError(send?.reason || 'Failed to send Qianwen prompt');
        }
        return [{ Status: 'sent', Prompt: prompt }];
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Scan the QR code with the Qianwen APP to log into qianwen.com in the automation browser, then rerun `qwen send`
  2. Persist the browser user-data directory so login survives across commands (send->ask sequences share the session)
  3. Check hasLoginGate selectors if you believe you are logged in — a UI change can cause false auth detection
  4. Avoid switching IPs/VPNs between login and send, as Qianwen may invalidate the session

Example fix

// before
await qwenSend(prompt); // fails with AUTH_REQUIRED in fresh profile
// after
await ensureQianwenSession(browser); // QR-login once with persisted profile
await qwenSend(prompt);
Defensive patterns

Strategy: validation

Validate before calling

async function requireQianwenLogin(page) {
  await ensureOnQianwen(page);
  if (await hasLoginGate(page)) throw new Error('Login to qianwen.com (QR via APP) before sending');
}
await requireQianwenLogin(page); // run before qwenSend

Try / catch

try {
  await qwenSend(prompt);
} catch (e) {
  if (isAuthError(e)) { await qrLoginThenPersistProfile(); return qwenSend(prompt); }
  throw e;
}

Prevention

When it happens

Trigger: `qwen send` (with optional think/research toggles) calls sendMessage(page, prompt); send.ok is falsy and hasLoginGate(page) detects a login wall/modal, so authRequired() is thrown before any message is submitted.

Common situations: Running send in a fresh browser profile that never logged in; cookies expired since last use; qianwen.com showing its login modal on load for the region/IP; VPN or IP change invalidating the session.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/dfb95f050ca9a1bd. Report an issue: GitHub.