jackwener/OpenCLI · error · AuthRequiredError
请在浏览器里用千问 APP 扫码登录 qianwen.com 后再重试。
Error message
请在浏览器里用千问 APP 扫码登录 qianwen.com 后再重试。
What it means
This is the Qianwen CLI's AuthRequiredError (built by authRequired() in clis/qwen/utils.js:22). It is thrown when the automation cannot prove the browser session is logged into qianwen.com, because the entire qwen workflow (sending prompts, reading replies) depends on an authenticated session. The message instructs the user to scan a QR code with the Qianwen mobile app to log in before retrying.
Source
Thrown at clis/qwen/ask.js:68
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);
// Anchor on the visible transcript BEFORE sending so waitForAnswer can
// bind the reply to the newly sent prompt instead of an older answer.
const baselineAnchor = await getBaselineChatAnchor(page);
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');
}
const result = await waitForAnswer(page, prompt, timeout, baselineAnchor);
if (result.status === 'auth_required') throw authRequired();
if (result.status === 'timeout') {
throw new TimeoutError('qianwen ask', timeout, 'No Qianwen reply observed before timeout. Retry with --timeout increased.');
}
const assistant = result.assistant;
if (!assistant) {
throw new CommandExecutionError('No assistant reply found in Qianwen chat.');
}
const answer = wantMarkdown && assistant.html
? (bubbleHtmlToMarkdown(assistant.html) || assistant.text)
: assistant.text;
return [
{ Role: 'User', Text: prompt },
{ Role: 'Assistant', Text: answer },View on GitHub (pinned to 49907e53dc)
Solutions
- Open qianwen.com in the automation browser and log in by scanning the QR code with the Qianwen mobile app, then rerun the command
- Persist the browser user-data/profile directory so the login cookie survives across runs
- Re-check hasLoginGate detection: if you ARE logged in but still see this, the login-gate selector may have changed and needs updating
- Rerun with a longer timeout in case the auth_required status came from a slow page load misdetected as a gate
Example fix
// before
await qwenAsk(prompt); // throws AuthRequiredError on expired session
// after
try {
await qwenAsk(prompt);
} catch (e) {
if (e.code === 'AUTH_REQUIRED') {
await loginQianwenViaQr(browser); // interactive QR login once, persisted profile
await qwenAsk(prompt);
}
} Defensive patterns
Strategy: try-catch
Validate before calling
const url = await page.evaluate('window.location.href').catch(() => '');
if (!url.includes('qianwen.com')) throw new Error('Not on qianwen.com — login first'); Type guard
function isAuthError(e) { return e && (e.code === 'AUTH_REQUIRED' || /扫码登录/.test(String(e.message))); } Try / catch
try {
await qwenAsk(prompt);
} catch (e) {
if (isAuthError(e)) {
await interactiveQianwenQrLogin();
return qwenAsk(prompt);
}
throw e;
} Prevention
- Log into qianwen.com once via QR scan and persist the browser user-data directory between runs
- Check login state (or call a cheap authenticated endpoint) before long commands
- Avoid clearing cookies or rotating IPs/VPNs mid-session
- Don't run concurrent sessions on the same Qianwen account that could invalidate each other
When it happens
Trigger: Running `qwen ask` when: (1) hasLoginGate(page) detects a login wall/modal after sendMessage fails to deliver the prompt, or (2) waitForAnswer reports result.status === 'auth_required' — i.e. the session was logged out or expired mid-conversation.
Common situations: The shared browser profile has no Qianwen login cookie or it expired; qianwen.com rotated its login wall so the session was invalidated; a fresh/incognito automation browser was used without prior manual login; a CAPTCHA or re-auth modal appeared mid-run.
Related errors
- 请在浏览器里用千问 APP 扫码登录 qianwen.com 后再重试。
- 请在浏览器里用千问 APP 扫码登录 qianwen.com 后再重试。
- 1point3acres Discuz *_auth cookie missing
- 需要登录一亩三分地后再使用该命令
- Cookie 已过期!请在当前 Chrome 浏览器中重新登录 BOSS 直聘。
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/178ab319b5a633f2.
Report an issue: GitHub.