jackwener/OpenCLI · error · AuthRequiredError

Note content requires login

Error message

Note content requires login

What it means

The extraction script detected data.loginWall, meaning the note detail page requires an authenticated session to view content. AuthRequiredError('www.xiaohongshu.com', 'Note content requires login') is thrown to tell the user to log in to Xiaohongshu in the connected Chrome browser.

Source

Thrown at clis/xiaohongshu/note.js:92

    ],
    columns: ['field', 'value'],
    func: async (page, kwargs) => {
        const raw = String(kwargs['note-id']);
        const noteId = parseNoteId(raw);
        const url = buildNoteUrl(raw, { commandName: 'xiaohongshu note' });
        await page.goto(url);
        await page.wait({ time: 2 + Math.random() * 3 });
        const data = await page.evaluate(NOTE_EXTRACT_JS);
        if (!data || typeof data !== 'object') {
            throw new EmptyResultError('xiaohongshu/note', '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 content requires login');
        }
        if (data.notFound) {
            throw new EmptyResultError('xiaohongshu/note', `Note ${noteId} not found or unavailable — it may have been deleted or restricted`);
        }
        const d = data;
        // XHS renders placeholder text like "赞"/"收藏"/"评论" when count is 0;
        // normalize to '0' unless the value looks numeric.
        const numOrZero = (v) => /^\d+/.test(v) ? v : '0';
        // A note may legitimately have no title, but a real note page always
        // renders an author. If both are missing, the page failed to load.
        if (!d.title && !d.author) {
            throw new EmptyResultError('xiaohongshu/note', 'The note page loaded without visible content. The note may be deleted or restricted.');
        }
        const rows = [
            { field: 'title', value: d.title || '' },
            { field: 'author', value: d.author || '' },
            { field: 'content', value: d.desc || '' },
            { field: 'likes', value: numOrZero(d.likes || '') },

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Log in to www.xiaohongshu.com in the Chrome instance the CLI drives, then rerun.
  2. Refresh the session if cookies expired (visit the site and confirm you stay logged in).
  3. Access the note from a context that doesn't require login (e.g. via a signed URL from search) if available.
  4. Check you are pointing the CLI at the correct Chrome profile.

Example fix

// before
// CLI attached to a fresh Chrome profile, not logged in
await note(url); // throws AuthRequiredError
// after
// open Chrome, log into www.xiaohongshu.com, then
await note(url);
Defensive patterns

Strategy: try-catch

Validate before calling

// Best-effort pre-check: confirm an auth cookie exists in the driven Chrome profile
// (real check requires browser access; the CLI throws AuthRequiredError otherwise)

Type guard

function isAuthRequiredError(err) {
  return err instanceof AuthRequiredError || err?.name === 'AuthRequiredError';
}

Try / catch

try {
  await note(url);
} catch (err) {
  if (isAuthRequiredError(err)) {
    console.error('Log in to www.xiaohongshu.com in the driven Chrome session, then retry.');
  } else throw err;
}

Prevention

When it happens

Trigger: page.evaluate(NOTE_EXTRACT_JS) returns { loginWall: true } — the page rendered a login prompt/gate instead of note content because the Chrome session is not logged in or the cookie session expired.

Common situations: Session cookies expired; using a fresh Chrome profile that never logged into XHS; XHS now gating note content behind login for that region/account; cookies cleared by browser updates.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/0702d80864544506. Report an issue: GitHub.