jackwener/OpenCLI · error · AuthRequiredError
登录超时(2分钟),请手动登录后重试
Error message
登录超时(2分钟),请手动登录后重试
What it means
If the automated login-wait loop cannot detect a logged-in weixin.qq.com session within 2 minutes, the command throws AuthRequiredError telling the user to log in manually. It is an authentication timeout, not a publish failure.
Source
Thrown at clis/wechat-channels/publish.js:616
process.stderr.write(
'\n⚠️ 未登录视频号。已跳转到登录页,请在 Chrome 中扫码登录...\n' +
' 登录完成后将自动继续发布。\n\n'
);
const loginDeadline = Math.min(deadline, Date.now() + 120_000);
let loggedIn = false;
while (Date.now() < loginDeadline) {
await page.wait({ time: 3 });
const url = await evalPage(page, '() => location.href');
if (!url.includes(LOGIN_PATH_FRAGMENT)) {
loggedIn = true;
break;
}
process.stderr.write(' 等待扫码中...\n');
}
if (!loggedIn) {
throw new AuthRequiredError('channels.weixin.qq.com', '登录超时(2分钟),请手动登录后重试');
}
process.stderr.write('✅ 登录成功,继续发布...\n\n');
await page.wait({ time: 3 }); // let bridge stabilize after login redirect
await page.goto(PUBLISH_URL);
await page.wait({ time: 5 });
}
}
// ── 4. Upload video ──────────────────────────────────────────────────
await uploadFile(page, videoPath);
await page.wait({ time: 2 });
// ── 5. Wait for upload + transcode done ──────────────────────────────
await waitForUploadDone(page, path.basename(videoPath), Math.min(180_000, remainingMs(deadline, '视频上传/转码')));
await page.wait({ time: 1 });
// ── 6. Fill title (主要内容) ─────────────────────────────────────────View on GitHub (pinned to 49907e53dc)
Solutions
- Scan the QR code promptly after the command starts, or pre-login via a persistent session (--site-session persistent)
- Run with persistent session, log in manually once in the browser, then re-run the command
- Increase the login wait window if 2 minutes is too short for your workflow
- Verify cookies are valid (not expired) before starting the publish
Example fix
// before
await cli.run('publish', { video: 'v.mp4' }); // fresh session, QR wait
// after
await cli.run('login', { siteSession: 'persistent' }); // one-time manual login
await cli.run('publish', { video: 'v.mp4', siteSession: 'persistent' }); Defensive patterns
Strategy: retry
Validate before calling
// pre-check for an existing session before starting the QR wait
const hasSession = await page.evaluate(() => document.cookie.includes('SESSDATA') || location.hostname !== 'channels.weixin.qq.com'); Try / catch
try {
await publishCmd(page, kwargs);
} catch (e) {
if (e instanceof AuthRequiredError && /登录超时/.test(e.message)) {
console.error('QR login timed out — log in via persistent session and retry.');
// e.g. await runLogin(page); then retry once
} else throw e;
} Prevention
- Use a persistent session and log in manually once beforehand
- Scan the QR code promptly after the command starts
- Keep cookies fresh; re-login when they expire
- Allow extra time in headless or slow-network environments
When it happens
Trigger: The polling loop never observed loggedIn=true before the 2-minute deadline: QR code not scanned, session cookie invalid, or login page redirected somewhere the loop does not detect.
Common situations: User did not scan the QR code in time; WeChat flagged the login and required extra verification; stale/expired cookies caused a login loop; headless environment where scanning is impossible.
Related errors
- 请先在共享 Chrome 完成 1688 登录/验证,再重试(${action})
- 1point3acres Discuz *_auth cookie missing
- 需要登录一亩三分地后再使用该命令
- Waiting for Bilibili session cookies
- Browser session required for bilibili comment
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/bb767ab8bc6dfd46.
Report an issue: GitHub.