jackwener/OpenCLI · error · AuthRequiredError
Douyin search results are blocked behind a login wall — log
Error message
Douyin search results are blocked behind a login wall — log in at https://www.douyin.com in Chrome first.
What it means
AuthRequiredError thrown when the Douyin search page's rendered DOM reports state === 'login_wall'. The search results page renders an empty/login-gated skeleton for visitors without an authenticated session, so the adapter refuses to pretend there are zero results and asks the user to log in via the bound Chrome profile.
Source
Thrown at clis/douyin/search.js:282
columns: ['rank', 'desc', 'author', 'url', 'plays', 'likes', 'comments', 'shares'],
func: async (page, kwargs) => {
const limit = parseSearchLimit(kwargs.limit);
const keyword = String(kwargs.query ?? '').trim();
if (!keyword) {
throw new ArgumentError('douyin search 需要 <query> 关键词');
}
await page.goto(`https://www.douyin.com/search/${encodeURIComponent(keyword)}?type=video`);
let result;
try {
result = unwrapEvaluateResult(await page.evaluate(WAIT_AND_EXTRACT_JS(RENDER_TIMEOUT_MS)));
} catch (error) {
throw new CommandExecutionError(`Douyin search extraction failed: ${error instanceof Error ? error.message : String(error)}`);
}
if (!result || typeof result !== 'object') {
throw new CommandExecutionError('Douyin search: unexpected evaluator payload shape');
}
if (result.state === 'login_wall') {
throw new AuthRequiredError(
'www.douyin.com',
'Douyin search results are blocked behind a login wall — log in at https://www.douyin.com in Chrome first.',
);
}
if (result.state === 'empty') {
throw new EmptyResultError('douyin search', `No Douyin videos matched "${keyword}".`);
}
if (result.state === 'timeout') {
throw new CommandExecutionError('Douyin search did not render result cards within the timeout. Open the same search in Chrome and verify login/security state before retrying.');
}
if (!Array.isArray(result.cards)) {
throw new CommandExecutionError('Douyin search: evaluator returned malformed cards payload');
}
if (result.cards.length === 0) {
throw new EmptyResultError('douyin search', `No Douyin videos matched "${keyword}".`);
}
const projected = projectSearchCards(result.cards, limit);
if (projected.invalidCount > 0) {View on GitHub (pinned to 49907e53dc)
Solutions
- Open https://www.douyin.com in the bound Chrome profile and log in manually, then retry the command.
- Confirm the CLI is attached to the intended Chrome profile (not a fresh/incognito one).
- If already logged in, complete any Douyin security/captcha verification in the browser and retry.
- Re-login to refresh expired cookies, then re-run.
Example fix
// no code fix; but callers can branch on the error type
// before
classifiedCLI(args).catch(e => { throw e; });
// after
import { AuthRequiredError } from '@jackwener/opencli/errors';
try {
return await douyinSearch(keyword);
} catch (e) {
if (e instanceof AuthRequiredError) {
console.error('Log in to douyin.com in Chrome, then retry');
return [];
}
throw e;
} Defensive patterns
Strategy: try-catch
Validate before calling
// before running: check login state in the bound profile
const loggedIn = await page.evaluate(() => !!document.querySelector('[data-e2e]') && document.cookie.includes('sessionid'));
if (!loggedIn) throw new Error('Log in to douyin.com in Chrome first'); Try / catch
import { AuthRequiredError } from '@jackwener/opencli/errors';
try {
rows = await douyinSearch(keyword);
} catch (e) {
if (e instanceof AuthRequiredError) {
console.error(`Auth required for ${e.domain ?? 'douyin'}: ${e.message}`);
process.exitCode = 3;
return;
}
throw e;
} Prevention
- Log in to www.douyin.com in the bound Chrome profile before scripting.
- Re-login periodically; Douyin sessions expire and get invalidated by risk control.
- Never point the CLI at an incognito or throwaway Chrome profile.
When it happens
Trigger: Running `douyin search` while the bound Chrome profile is logged out of www.douyin.com, the session cookie expired, Douyin invalidated the session (security check), or the wrong Chrome profile (without a Douyin login) is bound.
Common situations: Fresh machine/CI container where Chrome was never logged in; Douyin rotating sessions after risk control; cookie purge from clearing browser data; using a headless or brand-new profile.
Related errors
- 12306 tk auth cookie missing
- amazon.com
- Bilibili ${label} API requires login or permission: ${messag
- Boss wt2 / t cookies missing
- Waiting for Boss wt2 / t cookies
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/e1a593a73ca8431e.
Report an issue: GitHub.