jackwener/OpenCLI · error · AuthRequiredError
Note comments require login
Error message
Note comments require login
What it means
The extractor sets data.loginWall when the note detail page requires authentication to view comments. The command converts this into AuthRequiredError for www.xiaohongshu.com with the message 'Note comments require login', telling callers to authenticate the browser session.
Source
Thrown at clis/xiaohongshu/comments.js:315
columns: ['rank', 'author', 'userId', 'profileUrl', 'text', 'likes', 'time', 'is_reply', 'reply_to', 'images'],
func: async (page, kwargs) => {
const limit = parseCommentLimit(kwargs.limit);
const withReplies = Boolean(kwargs['with-replies']);
const raw = String(kwargs['note-id']);
const noteId = parseNoteId(raw);
await page.goto(buildNoteUrl(raw, { commandName: 'xiaohongshu comments' }));
await page.wait({ time: 2 + Math.random() * 3 });
const data = await page.evaluate(buildCommentsExtractJs(withReplies, limit));
if (!data || typeof data !== 'object') {
throw new EmptyResultError('xiaohongshu/comments', 'Unexpected evaluate response');
}
if (data.securityBlock) {
throw new CliError('SECURITY_BLOCK', 'Xiaohongshu security block: the note detail page was blocked by risk control.', /^https?:\/\//.test(raw)
? 'The page may be temporarily restricted. Try again later or from a different session.'
: 'Try using a full URL from search results (with xsec_token) instead of a bare note ID.');
}
if (data.loginWall) {
throw new AuthRequiredError('www.xiaohongshu.com', 'Note comments require login');
}
// noteId currently unused after parsing — kept for symmetry with the note command
void noteId;
const all = normalizeCommentRows(data.results, 'xiaohongshu/comments');
// authorHrefRaw is a raw transport field from the extractor; it is consumed
// here into userId / profileUrl and intentionally not part of the row shape.
const enrich = (c, i) => ({
rank: i + 1,
author: c.author,
userId: c.authorHrefRaw ? parseXhsProfileHref(c.authorHrefRaw) : '',
profileUrl: c.authorHrefRaw ? buildXhsProfileUrl(c.authorHrefRaw) : '',
text: c.text,
likes: c.likes,
time: c.time,
is_reply: c.is_reply,
reply_to: c.reply_to,
images: c.images ?? [],
});View on GitHub (pinned to 49907e53dc)
Solutions
- Log in once so the session cookies persist, then rerun the command
- Refresh/re-authenticate — cookies may have expired
- Check whether the specific note requires membership or is region-restricted
- Update the library if Xiaohongshu changed login-wall markup and the flag misfires
Example fix
// before
const cli = new XiaohongshuCli(); // anonymous session
await cli.comments(noteUrl);
// after
const cli = new XiaohongshuCli({ userDataDir: './xhs-profile' });
await cli.login(); // persist cookies once
await cli.comments(noteUrl); Defensive patterns
Strategy: try-catch
Try / catch
try {
const comments = await cli.comments(noteUrl);
} catch (err) {
if (err instanceof AuthRequiredError || /require login/i.test(err.message)) {
await cli.login(); // authenticate session then retry
return cli.comments(noteUrl);
}
throw err;
} Prevention
- Log in once and persist cookies (userDataDir) before scraping
- Refresh sessions before they expire
- Skip notes known to require membership/login for comments
- Watch for Xiaohongshu policy changes requiring login for comments
When it happens
Trigger: page.evaluate returns { loginWall: true } — the page rendered a login prompt/redirect instead of the comment list, typically for notes whose comments are members-only or when the session is anonymous.
Common situations: Running without a logged-in session (no cookies persisted); Xiaohongshu now requires login for comment viewing where it previously did not (policy change); expired session cookies; accessing comments of restricted/PGC notes.
Related errors
- ChatGPT project requires a logged-in ChatGPT session.
- Claude requires a logged-in browser session.
- [taxonomy=selector_drift] site=powerchina command=search log
- Xianyu item detail requires a logged-in browser session
- Xiaohongshu collection page requires login; re-login to xiao
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/82c5ec5d07853386.
Report an issue: GitHub.