jackwener/OpenCLI · error · AuthRequiredError

${result.detail}

Error message

${result.detail}

What it means

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.

Source

Thrown at clis/weread/auth.js:39

      const res = await fetch('/web/user', { credentials: 'include', headers: { 'Accept': 'application/json' } });
      if (res.status === 401 || res.status === 403) {
        return { kind: 'auth', detail: 'WeRead /web/user HTTP ' + res.status };
      }
      if (!res.ok) return { kind: 'http', httpStatus: res.status };
      const d = await res.json();
      if (d && d.errCode && d.errCode !== 0) {
        return { kind: 'auth', detail: 'WeRead /web/user errCode=' + d.errCode };
      }
      return {
        ok: true,
        user_id: String(d.userVid || wrVid),
        name: String(d.name || d.nickName || ''),
      };
    } catch (e) {
      return { kind: 'exception', detail: String(e && e.message || e) };
    }
  })()`);
  if (result?.kind === 'auth') throw new AuthRequiredError('weread.qq.com', result.detail);
  if (result?.kind === 'http') throw new CommandExecutionError(`HTTP ${result.httpStatus} from /web/user`);
  if (result?.kind === 'exception') throw new CommandExecutionError(`WeRead whoami failed: ${result.detail}`);
  if (!result?.ok) throw new CommandExecutionError(`Unexpected WeRead probe: ${JSON.stringify(result)}`);
  return { user_id: result.user_id, name: result.name };
}

registerSiteAuthCommands({
  site: 'weread',
  domain: 'weread.qq.com',
  loginUrl: 'https://weread.qq.com/',
  columns: ['user_id', 'name'],
  quickCheck: hasWereadSessionCookie,
  verify: verifyWereadIdentity,
  poll: async (page) => {
    if (!await hasWereadSessionCookie(page)) {
      throw new AuthRequiredError('weread.qq.com', 'Waiting for WeRead wr_vid cookie');
    }
    return verifyWereadIdentity(page);

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Log in again at https://weread.qq.com/ in the attached browser to refresh the full session (wr_vid and wr_skey).
  2. Read the detail message: 'HTTP 401/403' means session rejected; 'errCode=' gives WeRead's own code.
  3. Clear weread.qq.com cookies and log in fresh if refreshing does not fix it.
  4. Confirm the account is not blocked/restricted by loading /web/user manually in the browser.

Example fix

// before: stale session
AuthRequiredError: weread.qq.com: WeRead /web/user HTTP 401
// after: refresh login in the attached browser, then retry the command
Defensive patterns

Strategy: try-catch

Try / catch

try { const identity = await verifyWereadIdentity(page); } catch (e) {
  if (e instanceof AuthRequiredError) {
    console.error('WeRead session invalid — re-login at https://weread.qq.com/ and retry.');
  } else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/a993158c734acb2c. Report an issue: GitHub.