jackwener/OpenCLI · error · AuthRequiredError
Yuanbao showed wx login gate — anonymous session
Error message
Yuanbao showed wx login gate — anonymous session
What it means
An AuthRequiredError thrown by verifyYuanbaoIdentity when the Yuanbao page currently shows the WeChat login gate, meaning the browser session is anonymous (not logged in). The library calls this verifier before any authenticated Yuanbao operation; a visible login gate proves there is no usable session, so it fails with an auth-required signal pointing at the Yuanbao domain.
Source
Thrown at clis/yuanbao/auth.js:13
import { AuthRequiredError, CommandExecutionError } from '@jackwener/opencli/errors';
import { registerSiteAuthCommands } from '../_shared/site-auth.js';
import { hasLoginGate, ensureYuanbaoPage, YUANBAO_DOMAIN, YUANBAO_URL } from './shared.js';
async function hasYuanbaoUserCookie(page) {
const cookies = await page.getCookies({ url: 'https://yuanbao.tencent.com' });
return cookies.some(c => c.name === 'hy_user' && c.value);
}
async function verifyYuanbaoIdentity(page) {
await ensureYuanbaoPage(page);
if (await hasLoginGate(page)) {
throw new AuthRequiredError(YUANBAO_DOMAIN, 'Yuanbao showed wx login gate — anonymous session');
}
const cookies = await page.getCookies({ url: 'https://yuanbao.tencent.com' });
const hyUser = cookies.find(c => c.name === 'hy_user')?.value || '';
if (!hyUser) {
throw new AuthRequiredError(YUANBAO_DOMAIN, 'Yuanbao hy_user cookie missing — anonymous session');
}
const probe = await page.evaluate(`
(() => {
const bodyText = document.body?.innerText || '';
const nickMatch = bodyText.match(/用户[a-z0-9]{4,}/i);
const state = window.__INITIAL_STATE__ || {};
const seen = new Set();
const stack = [state];
let stateNick = '';
while (stack.length) {
const node = stack.pop();
if (!node || typeof node !== 'object' || seen.has(node)) continue;
seen.add(node);View on GitHub (pinned to 49907e53dc)
Solutions
- Run the yuanbao login flow to establish an authenticated session (scan the WeChat QR).
- Re-import fresh Yuanbao cookies if you manage sessions manually.
- Verify the persistent session profile wasn't cleared before running commands.
Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-flight check before any authenticated yuanbao call
const cookies = await page.getCookies({ url: 'https://yuanbao.tencent.com' });
if (!cookies.some(c => c.name === 'hy_user' && c.value)) {
await run(['yuanbao', 'login']);
} Type guard
const hasYuanbaoUserCookie = (cookies) => Array.isArray(cookies) && cookies.some(c => c.name === 'hy_user' && !!c.value);
Try / catch
try {
await run(['yuanbao', 'detail', url]);
} catch (e) {
if (e.name === 'AuthRequiredError' || /login gate/.test(e.message)) {
await run(['yuanbao', 'login']);
return run(['yuanbao', 'detail', url]);
}
throw e;
} Prevention
- Run the login flow proactively when hy_user is missing or stale
- Check cookie presence before batch runs
- Don't share/clear the persistent browser profile between runs
- Handle AuthRequiredError by routing to login, not retrying blind
When it happens
Trigger: Running any yuanbao command that verifies identity (login quickCheck/verify, or flows calling verifyYuanbaoIdentity) when cookies are absent/expired and the site renders its wx login gate instead of the app.
Common situations: Expired hy_user session cookies; fresh environment never logged in; cookies cleared by browser cleanup; logging in on one machine profile and running the CLI against another.
Related errors
- ChatGPT requires a logged-in browser session.
- Yuanbao hy_user cookie missing — anonymous session
- Waiting for Yuanbao hy_user cookie
- AUTH_REQUIRED
- AUTH_REQUIRED
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/c8a0bc183c1d7382.
Report an issue: GitHub.