jackwener/OpenCLI · error · AuthRequiredError
${probe.detail}
Error message
${probe.detail} What it means
After loading i.chaoxing.com, verifyChaoxingIdentity runs an in-page probe that classifies the result. If the probe returns kind:'auth' (no user identity surface — page is effectively anonymous, e.g. redirected toward passport2 login), the library throws AuthRequiredError with the probe's own detail message. Cookies existed but the site does not recognize the session.
Source
Thrown at clis/chaoxing/auth.js:36
return { kind: 'auth', detail: 'Chaoxing i.chaoxing.com redirected to passport2 login' };
}
const userIdCookie = (document.cookie.split('; ').find(c => /^(_uid|UID)=/.test(c)) || '').split('=')[1] || '';
let userName = '';
const unameCookie = (document.cookie.split('; ').find(c => /^uname=/.test(c)) || '').split('=')[1] || '';
if (unameCookie) {
try { userName = decodeURIComponent(unameCookie); } catch { userName = unameCookie; }
}
if (!userName) {
const el = document.querySelector('.userTitle, .myInfo, .user-name, [class*=userName]');
userName = (el?.innerText || '').trim();
}
if (!userIdCookie && !userName) {
return { kind: 'auth', detail: 'Chaoxing i.chaoxing.com no user identity surface — anonymous' };
}
return { ok: true, user_id: userIdCookie, name: userName };
})()
`);
if (probe?.kind === 'auth') throw new AuthRequiredError('chaoxing.com', probe.detail);
if (!probe?.ok) throw new CommandExecutionError(`Unexpected Chaoxing probe: ${JSON.stringify(probe)}`);
return { user_id: probe.user_id, name: probe.name };
}
registerSiteAuthCommands({
site: 'chaoxing',
domain: 'chaoxing.com',
loginUrl: 'https://passport2.chaoxing.com/login?fid=&newversion=true&refer=https%3A%2F%2Fi.chaoxing.com',
columns: ['user_id', 'name'],
quickCheck: hasChaoxingSessionCookie,
verify: verifyChaoxingIdentity,
poll: async (page) => {
if (!await hasChaoxingSessionCookie(page)) {
throw new AuthRequiredError('chaoxing.com', 'Waiting for Chaoxing session cookies');
}
return verifyChaoxingIdentity(page);
},
});View on GitHub (pinned to 49907e53dc)
Solutions
- Re-login via the chaoxing login command and retry identity verification
- Delete stale cookies and perform a fresh full login
- Check for a redirect to passport2.chaoxing.com/login — that confirms the session is dead
- If it persists, the account may be under risk control; log in manually in the automation browser once
Example fix
// before
if (probe?.kind === 'auth') throw new AuthRequiredError('chaoxing.com', probe.detail);
// after
if (probe?.kind === 'auth') {
await login(page); // refresh dead session
return verifyChaoxingIdentity(page); // retry once
} Defensive patterns
Strategy: try-catch
Validate before calling
// cookie presence alone is insufficient; probe after login
await page.goto('https://i.chaoxing.com/');
if (/passport2\.chaoxing\.com\/login/.test(page.url())) await chaoxingLogin(page); Type guard
function probeOk(p) { return !!p && (p.kind === 'auth' || p.ok === true); } Try / catch
try { const id = await whoami(page); }
catch (e) { if (e instanceof AuthRequiredError) { await login(page); return whoami(page); } throw e; } Prevention
- Check page.url() for a login redirect before probing
- Re-login whenever the probe reports anonymous — stale cookies don't imply a live session
- Handle multi-device logout: sessions die server-side
- Automate one re-login + retry on AuthRequiredError
When it happens
Trigger: Cookies pass the local check but the server session is dead (expired server-side), so i.chaoxing.com renders anonymous/login state and the probe reports no user identity.
Common situations: Server-side session expiry while stale client cookies remain; account logged out from another device; ip/risk control invalidating the session.
Related errors
- 请先在共享 Chrome 完成 1688 登录/验证,再重试(${action})
- Bilibili ${label} API requires login or permission: ${messag
- bilibili.com
- 未获取到课程列表
- Chaoxing session cookies missing
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/48f869f696b07a2a.
Report an issue: GitHub.