jackwener/OpenCLI · error · AuthRequiredError

Toutiao creator articles require a logged-in mp.toutiao.com…

Error message

Toutiao creator articles require a logged-in mp.toutiao.com browser session

What it means

After rendering the Toutiao creator articles page, looksToutiaoAuthWallText(text) detects login-wall copy in the extracted text and the command throws AuthRequiredError('mp.toutiao.com', 'Toutiao creator articles require a logged-in mp.toutiao.com browser session'). It distinguishes an auth wall from an empty result so the user knows to log in rather than debug parsing.

Solutions

  1. Log in to mp.toutiao.com in the automated browser profile (scan QR code) and rerun
  2. Use a persistent user-data-dir so the creator session survives restarts
  3. Refresh/replace expired session cookies for mp.toutiao.com
  4. Confirm the page really shows the login wall (log the extracted text) to rule out false-positive text matching

Example fix

// before
await page.goto('https://mp.toutiao.com/...'); // logged-out profile
// after
await context.storageState({ path: 'toutiao-state.json' }); // reuse saved session
await page.goto('https://mp.toutiao.com/...');
Defensive patterns

Strategy: validation

Validate before calling

const text = await page.evaluate(() => document.body.innerText);
if (/登录|扫码|login|scan qr/i.test(text) && !/文章|articles/i.test(text)) {
  throw new Error('AUTH_REQUIRED: mp.toutiao.com login wall detected');
}

Type guard

function isAuthWall(text) { return typeof text === 'string' && /登录|扫码登录|请登录/i.test(text); }

Try / catch

try { await fetchToutiaoArticles(); } catch (e) {
  if (e instanceof AuthRequiredError) {
    await openMpToutiaoLoginAndScanQr(); // manual one-time login
    return fetchToutiaoArticles();
  }
  throw e;
}

Prevention

When it happens

Trigger: The rendered page's innerText matched the toutiao auth-wall heuristics — mp.toutiao.com served its login prompt instead of the article list because no valid creator session exists.

Common situations: Browser profile not logged into mp.toutiao.com; Toutiao session cookie (tt_webid / sessionid) expired; QR-code re-login forced by Toutiao after risk-control checks; automated browser using a fresh profile each run.

Related errors


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

Appendix: source

Thrown at clis/toutiao/articles.js:38

    columns: ['title', 'date', 'status', '展现', '阅读', '点赞', '评论'],
    func: async (page, kwargs) => {
        const articlePage = parseArticlesPage(kwargs.page, 1);
        let text;
        try {
            await page.goto(`https://mp.toutiao.com/profile_v4/manage/content/all?page=${articlePage}`);
            await page.wait('networkidle');
            await page.wait(3);
            text = await page.evaluate(`
(async () => {
    await new Promise(r => setTimeout(r, 2000));
    return document.body.innerText || '';
})()
`);
        } catch (error) {
            throw new CommandExecutionError(`toutiao articles render failed: ${error?.message || error}`);
        }
        if (looksToutiaoAuthWallText(text)) {
            throw new AuthRequiredError('mp.toutiao.com', 'Toutiao creator articles require a logged-in mp.toutiao.com browser session');
        }
        const rows = parseToutiaoArticlesText(text);
        if (rows.length === 0) {
            throw new EmptyResultError(
                'toutiao articles',
                `未抓取到创作者后台文章 (page=${articlePage})。可能页面尚未完成渲染或无文章。`,
            );
        }
        return rows;
    },
});

export { parseToutiaoArticlesText };
export const __test__ = {
    parseToutiaoArticlesText,
    parseArticlesPage,
};

View on GitHub (pinned to 49907e53dc)