{"record":{"id":"521e81e456c423e8","repo":"jackwener/OpenCLI","slug":"waiting-for-bilibili-session-cookies","errorCode":null,"errorMessage":"Waiting for Bilibili session cookies","messagePattern":"Waiting for Bilibili session cookies","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"warning","filePath":"clis/bilibili/auth.js","lineNumber":32,"sourceCode":"  const payload = await apiGet(page, '/x/space/wbi/acc/info', { params: { mid: uid }, signed: true });\n  const data = payload?.data ?? {};\n  return {\n    id: String(data.mid ?? uid),\n    username: data.name ?? '',\n    level: data.level ?? 0,\n  };\n}\n\nregisterSiteAuthCommands({\n  site: 'bilibili',\n  domain: 'www.bilibili.com',\n  loginUrl: 'https://passport.bilibili.com/login',\n  columns: ['id', 'username', 'level'],\n  quickCheck: hasBilibiliSessionCookies,\n  verify: verifyBilibiliIdentity,\n  poll: async (page) => {\n    if (!await hasBilibiliSessionCookies(page)) {\n      throw new AuthRequiredError('bilibili.com', 'Waiting for Bilibili session cookies');\n    }\n    return verifyBilibiliIdentity(page);\n  },\n});\n","sourceCodeStart":14,"sourceCodeEnd":37,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/bilibili/auth.js#L14-L37","documentation":"During interactive Bilibili login the CLI polls the browser page until session cookies (SESSDATA etc.) appear. If a poll tick finds the cookies still absent it throws AuthRequiredError with this message, signalling login has not completed yet rather than a hard failure.","triggerScenarios":"The poll callback runs hasBilibiliSessionCookies(page) after the user is shown the passport.bilibili.com login page and the cookies are not yet set — e.g. user has not finished logging in, or the login was aborted/cancelled before cookies were stored.","commonSituations":"User closes the browser window mid-login; QR-code/credentials flow not completed within the poll window; login page open in a different browser profile than the automated session; region-blocked login preventing session establishment.","solutions":["Complete the login in the opened browser page (scan QR or enter credentials) and let polling continue","Re-run the login command and keep the browser open until the CLI reports success","Confirm the automated browser profile is the one being logged into (no competing sessions)","Check bilibili.com is reachable and not blocked by proxy/VPN"],"exampleFix":"// before\nawait cli.login(); // throws while cookies absent\n// after\ntry { await cli.login(); } catch (e) { console.log('Finish login in the browser, then retry'); }","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await login(); } catch (e) { if (String(e.message).includes('Waiting for Bilibili session cookies')) { await sleep(pollInterval); return login(); } throw e; }","preventionTips":["Complete the login in the opened browser before the poll window ends","Keep the automated browser open until the CLI confirms success","Ensure no VPN/proxy blocks passport.bilibili.com","Re-run login when cookies expire"],"tags":["auth","cookies","login","polling"],"backgroundTag":"auth-session-cookies-missing","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}