jackwener/OpenCLI · error · AuthRequiredError
${probe.detail}
Error message
${probe.detail} What it means
Thrown by verifyMaimaiIdentity in clis/maimai/auth.js:33 when the in-page WHOAMI_PROBE returns kind:'auth', meaning the inline userObj JSON (only injected for authenticated maimai.cn sessions) was absent. AuthRequiredError('maimai.cn', probe.detail) surfaces detail such as 'Maimai userObj missing from page (anonymous)', i.e. you are not logged in.
Source
Thrown at clis/maimai/auth.js:33
if (m) { try { user = JSON.parse(m[1]); } catch {} break; }
}
if (!user || !user.id) return { kind: 'auth', detail: 'Maimai userObj missing from page (anonymous)' };
return {
ok: true,
user_id: String(user.id),
name: String(user.name || ''),
company: String(user.company || ''),
};
} catch (e) {
return { kind: 'exception', detail: String(e && e.message || e) };
}
})()`;
async function verifyMaimaiIdentity(page) {
await page.goto('https://maimai.cn/');
await page.wait(2);
const probe = await page.evaluate(WHOAMI_PROBE);
if (probe?.kind === 'auth') throw new AuthRequiredError('maimai.cn', probe.detail);
if (probe?.kind === 'http') throw new CommandExecutionError(`HTTP ${probe.httpStatus} from Maimai`);
if (probe?.kind === 'exception') throw new CommandExecutionError(`Maimai whoami failed: ${probe.detail}`);
if (!probe?.ok) throw new CommandExecutionError(`Unexpected Maimai probe: ${JSON.stringify(probe)}`);
return { user_id: probe.user_id, name: probe.name, company: probe.company };
}
registerSiteAuthCommands({
site: 'maimai',
domain: 'maimai.cn',
loginUrl: 'https://maimai.cn/',
columns: ['user_id', 'name', 'company'],
verify: verifyMaimaiIdentity,
poll: verifyMaimaiIdentity,
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Open https://maimai.cn/ in the browser used by the CLI and log in
- Re-run the verify/login command after logging in
- If recently logged in, reload maimai.cn so userObj is injected, then retry
- Clear stale cookies and log in again if the session is half-expired
Example fix
// before (anonymous session)
await verifyMaimaiIdentity(page); // throws AuthRequiredError
// after
await openBrowserAndLogin('https://maimai.cn/'); // user completes login manually
await verifyMaimaiIdentity(page); // succeeds once userObj present Defensive patterns
Strategy: try-catch
Validate before calling
// before verifying, ensure a login cookie exists
const cookies = await page.getCookies({ url: 'https://maimai.cn' });
const hasSession = cookies.some(c => c.name.startsWith('user') || /sess|token/i.test(c.name));
if (!hasSession) throw new Error('Log in at maimai.cn first'); Type guard
function isAuthError(e) {
return e && (e.name === 'AuthRequiredError' || /maimai\.cn.*login|userObj missing/i.test(e.message));
} Try / catch
try {
await verifyMaimaiIdentity(page);
} catch (e) {
if (isAuthError(e)) {
console.error('Not logged into maimai.cn — open it in the browser and log in, then retry');
return { needsLogin: true };
}
throw e;
} Prevention
- Log into maimai.cn in the CLI's browser profile before running commands
- Check session-cookie presence before batch operations
- Re-login when sessions expire (maimai sessions are not permanent)
- Keep the browser profile persistent so cookies survive restarts
When it happens
Trigger: Running the maimai auth check (or any cookie-strategy maimai command that verifies identity) while the shared Chrome session has no valid maimai.cn login, the session cookie expired, or the page loaded an anonymous variant missing userObj.
Common situations: Logged out of maimai.cn in the browser; session cookie expired after inactivity; using a fresh browser profile; maimai serving a logged-out homepage variant due to region/AB test.
Related errors
- AuthRequiredError('gitee.com', 'Waiting for Gitee login')
- Browser session required for bilibili subtitle
- Bilibili subtitles are hidden behind login for this video. P
- Browser session required for bilibili summary
- Browser session required for bilibili unfollow
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/4afde84960927729.
Report an issue: GitHub.