{"record":{"id":"a993158c734acb2c","repo":"jackwener/OpenCLI","slug":"result-detail-a99315","errorCode":null,"errorMessage":"${result.detail}","messagePattern":"\\$\\{result\\.detail\\}","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/weread/auth.js","lineNumber":39,"sourceCode":"      const res = await fetch('/web/user', { credentials: 'include', headers: { 'Accept': 'application/json' } });\n      if (res.status === 401 || res.status === 403) {\n        return { kind: 'auth', detail: 'WeRead /web/user HTTP ' + res.status };\n      }\n      if (!res.ok) return { kind: 'http', httpStatus: res.status };\n      const d = await res.json();\n      if (d && d.errCode && d.errCode !== 0) {\n        return { kind: 'auth', detail: 'WeRead /web/user errCode=' + d.errCode };\n      }\n      return {\n        ok: true,\n        user_id: String(d.userVid || wrVid),\n        name: String(d.name || d.nickName || ''),\n      };\n    } catch (e) {\n      return { kind: 'exception', detail: String(e && e.message || e) };\n    }\n  })()`);\n  if (result?.kind === 'auth') throw new AuthRequiredError('weread.qq.com', result.detail);\n  if (result?.kind === 'http') throw new CommandExecutionError(`HTTP ${result.httpStatus} from /web/user`);\n  if (result?.kind === 'exception') throw new CommandExecutionError(`WeRead whoami failed: ${result.detail}`);\n  if (!result?.ok) throw new CommandExecutionError(`Unexpected WeRead probe: ${JSON.stringify(result)}`);\n  return { user_id: result.user_id, name: result.name };\n}\n\nregisterSiteAuthCommands({\n  site: 'weread',\n  domain: 'weread.qq.com',\n  loginUrl: 'https://weread.qq.com/',\n  columns: ['user_id', 'name'],\n  quickCheck: hasWereadSessionCookie,\n  verify: verifyWereadIdentity,\n  poll: async (page) => {\n    if (!await hasWereadSessionCookie(page)) {\n      throw new AuthRequiredError('weread.qq.com', 'Waiting for WeRead wr_vid cookie');\n    }\n    return verifyWereadIdentity(page);","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/weread/auth.js#L21-L57","documentation":"verifyWereadIdentity in clis/weread/auth.js throws AuthRequiredError when the in-page probe of /web/user reports kind:'auth' — the wr_vid cookie is absent in document.cookie, the /web/user endpoint returned 401/403, or the JSON body carried a non-zero errCode. It signals the WeRead session is invalid or insufficient despite passing the quick cookie check.","triggerScenarios":"wr_vid exists but other session cookies (wr_skey etc.) are missing/expired, so the in-page fetch of /web/user with credentials:'include' returns 401/403 or errCode != 0 inside page.evaluate; also when document.cookie lacks wr_vid due to HttpOnly or a different cookie scope.","commonSituations":"Expired WeRead session where wr_vid persists but wr_skey has rotated out; account logged in elsewhere invalidating the session; WeRead returning errCode for not-logged-in state; cookie visibility differences between page.getCookies and document.cookie.","solutions":["Log in again at https://weread.qq.com/ in the attached browser to refresh the full session (wr_vid and wr_skey).","Read the detail message: 'HTTP 401/403' means session rejected; 'errCode=' gives WeRead's own code.","Clear weread.qq.com cookies and log in fresh if refreshing does not fix it.","Confirm the account is not blocked/restricted by loading /web/user manually in the browser."],"exampleFix":"// before: stale session\nAuthRequiredError: weread.qq.com: WeRead /web/user HTTP 401\n// after: refresh login in the attached browser, then retry the command","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { const identity = await verifyWereadIdentity(page); } catch (e) {\n  if (e instanceof AuthRequiredError) {\n    console.error('WeRead session invalid — re-login at https://weread.qq.com/ and retry.');\n  } else throw e;\n}","preventionTips":["Re-login whenever WeRead rotates wr_skey/session","Avoid using the same WeRead account in many places simultaneously","Clear weread.qq.com cookies and log in fresh after repeated auth errors","Keep the browser open on weread.qq.com during verification"],"tags":["auth","cookies","session-expired","weread"],"backgroundTag":"auth-session-expired","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}