jackwener/OpenCLI · error · AuthRequiredError
Douban dbcl2 / ck cookies missing
Error message
Douban dbcl2 / ck cookies missing
What it means
verifyDoubanIdentity inspects the browser's cookies for douban.com and requires an authenticated session, detected via the dbcl2 or ck cookies set after Douban login. It throws AuthRequiredError when neither cookie exists, meaning the reused browser profile is not logged in to douban.com.
Source
Thrown at clis/douban/auth.js:21
async function hasDoubanSessionCookie(page) {
const cookies = await page.getCookies({ url: 'https://www.douban.com' });
const names = new Set(cookies.map(c => c.name));
return names.has('dbcl2') || names.has('ck');
}
function parseDoubanUserId(value) {
const text = String(value ?? '');
return text.match(/(?:^|\/)people\/(\d+)\/?/)?.[1]
|| text.match(/^"?(\d+):/)?.[1]
|| '';
}
async function verifyDoubanIdentity(page) {
const cookies = await page.getCookies({ url: 'https://www.douban.com' });
const names = new Set(cookies.map(c => c.name));
if (!names.has('dbcl2') && !names.has('ck')) {
throw new AuthRequiredError('douban.com', 'Douban dbcl2 / ck cookies missing');
}
const cookieUid = parseDoubanUserId(cookies.find(c => c.name === 'dbcl2')?.value);
await page.goto('https://www.douban.com/mine/');
await page.wait(2);
const probe = await page.evaluate(`
(() => {
const parseUid = (value) => String(value || '').match(/(?:^|\\/)people\\/(\\d+)\\/?/)?.[1] || '';
const currentUrl = new URL(window.location.href);
if (currentUrl.hostname === 'accounts.douban.com' || currentUrl.pathname.startsWith('/passport/')) {
return { kind: 'auth', detail: 'Douban /mine redirected to the login flow' };
}
const navUser = document.querySelector('.nav-user-account .bn-more, .top-nav-info a.bn-more');
const navHref = navUser?.getAttribute('href') || navUser?.href || '';
const user_id = parseUid(window.location.href) || parseUid(navHref);
const name = (navUser?.textContent || document.querySelector('.info h1, h1')?.textContent || '').trim();
return user_id
? { ok: true, user_id, name }
: { kind: 'unknown', detail: 'Douban user_id parse failed: href=' + navHref + ' location=' + window.location.href };View on GitHub (pinned to 49907e53dc)
Solutions
- Run the douban login flow (opencli site auth for douban) and sign in at accounts.douban.com/passport/login in the reused browser
- Manually log in to douban.com in the browser profile opencli reuses, then rerun
- Verify cookies exist: document.cookie or devtools on www.douban.com should show dbcl2 or ck
Defensive patterns
Strategy: try-catch
Validate before calling
const cookies = await page.getCookies({ url: 'https://www.douban.com' });
const ok = cookies.some(c => c.name === 'dbcl2' || c.name === 'ck');
if (!ok) console.error('Not logged in to douban.com — run the login flow first'); Type guard
function hasDoubanCookies(cookies) { return cookies.some(c => c.name === 'dbcl2' || c.name === 'ck'); } Try / catch
try { await verifyDoubanIdentity(page); } catch (e) { if (e instanceof AuthRequiredError) { await runDoubanLogin(); return verifyDoubanIdentity(page); } throw e; } Prevention
- Run the login/auth check before batch jobs
- Persist and reuse the same browser profile that holds the douban session
- Detect 'Waiting for dbcl2 / ck cookies' polls and surface a login prompt
When it happens
Trigger: Running any authenticated douban command with a fresh/incognito browser profile; after clearing cookies; on a machine whose browser was never signed in to douban.com; after Douban session expiry removed the cookies.
Common situations: CI or headless environments with no logged-in profile; switching browser profiles; a long-lived session silently expiring so the cookies disappear.
Related errors
- 1point3acres Discuz *_auth cookie missing
- dianping.com
- ${probe.detail}
- Waiting for Douban dbcl2 / ck cookies
- AUTH_REQUIRED
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/87976e04a1448962.
Report an issue: GitHub.