{"record":{"id":"7466ed219a1be520","repo":"jackwener/OpenCLI","slug":"probe-detail-7466ed","errorCode":null,"errorMessage":"${probe.detail}","messagePattern":"\\$\\{probe\\.detail\\}","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/douban/auth.js","lineNumber":45,"sourceCode":"    (() => {\n      const parseUid = (value) => String(value || '').match(/(?:^|\\\\/)people\\\\/(\\\\d+)\\\\/?/)?.[1] || '';\n      const currentUrl = new URL(window.location.href);\n      if (currentUrl.hostname === 'accounts.douban.com' || currentUrl.pathname.startsWith('/passport/')) {\n        return { kind: 'auth', detail: 'Douban /mine redirected to the login flow' };\n      }\n      const navUser = document.querySelector('.nav-user-account .bn-more, .top-nav-info a.bn-more');\n      const navHref = navUser?.getAttribute('href') || navUser?.href || '';\n      const user_id = parseUid(window.location.href) || parseUid(navHref);\n      const name = (navUser?.textContent || document.querySelector('.info h1, h1')?.textContent || '').trim();\n      return user_id\n        ? { ok: true, user_id, name }\n        : { kind: 'unknown', detail: 'Douban user_id parse failed: href=' + navHref + ' location=' + window.location.href };\n    })()\n  `);\n  if (probe?.kind === 'unknown' && cookieUid) {\n    return { user_id: cookieUid, name: '' };\n  }\n  if (probe?.kind === 'auth') throw new AuthRequiredError('douban.com', probe.detail);\n  if (!probe?.ok) throw new CommandExecutionError(`Unexpected Douban probe: ${JSON.stringify(probe)}`);\n  return { user_id: probe.user_id, name: probe.name };\n}\n\nregisterSiteAuthCommands({\n  site: 'douban',\n  domain: 'douban.com',\n  loginUrl: 'https://accounts.douban.com/passport/login',\n  columns: ['user_id', 'name'],\n  quickCheck: hasDoubanSessionCookie,\n  verify: verifyDoubanIdentity,\n  poll: async (page) => {\n    if (!await hasDoubanSessionCookie(page)) {\n      throw new AuthRequiredError('douban.com', 'Waiting for Douban dbcl2 / ck cookies');\n    }\n    return verifyDoubanIdentity(page);\n  },\n});","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/douban/auth.js#L27-L63","documentation":"verifyDoubanIdentity probes the /mine/ page in the browser to determine the logged-in user. When the probe returns kind 'auth' the page shows a login/blocked state, so the library raises AuthRequiredError with the probe's detail text describing what it observed (e.g. a login redirect).","triggerScenarios":"dbcl2/ck cookie exists but is expired or invalid, so /mine/ redirects to login; douban anti-bot challenge (sec.douban.com) intercepts the probe; the page's nav links contain no parsable user id and the probe classifies the state as an auth wall.","commonSituations":"Session cookie survives but the server-side session was revoked; risk-control blocking of automated access; logging out in the browser while cookies linger.","solutions":["Re-authenticate: run the douban login flow and sign in again in the reused browser","Open douban.com in that browser manually and complete any captcha/risk-control challenge, then retry","Clear stale douban cookies and log in fresh"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"await page.goto('https://www.douban.com/mine/');\nconst loggedIn = !page.url().includes('accounts.douban.com/passport/login');\nif (!loggedIn) await runDoubanLogin();","typeGuard":"function probeLooksAuthBlocked(probe) { return probe && probe.kind === 'auth'; }","tryCatchPattern":"try { const id = await verifyDoubanIdentity(page); } catch (e) { if (e instanceof AuthRequiredError) { console.error('Douban session invalid — re-login in the reused browser:', e.message); } else throw e; }","preventionTips":["Re-login when dbcl2/ck cookies are stale rather than reusing them","Complete captcha/risk-control challenges manually before automation","Keep the interactive login browser and automation profile identical"],"tags":["auth","douban","session-expired","login-required"],"backgroundTag":"session-expired-redirect","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}