jackwener/OpenCLI · error · AuthRequiredError
weibo.com
Error message
weibo.com
What it means
When mapError() detects auth-related keywords in the underlying error message (login, cookie, 登录, auth, forbidden, permission, 权限, unauthorized), it classifies the failure as an authentication problem for weibo.com and throws AuthRequiredError('weibo.com', message). The message shown is 'weibo.com' — the site that requires valid credentials.
Source
Thrown at clis/weibo/user-posts.js:68
}
function dateToTimestamp(date) {
return Math.floor(new Date(`${date}T00:00:00+08:00`).getTime() / 1000);
}
function validateRange(start, end) {
if (start && end && dateToTimestamp(start) > dateToTimestamp(end)) {
throw new ArgumentError('weibo user-posts start must be <= end');
}
}
function mapError(error) {
const message = String(error ?? '').trim();
if (!message) {
throw new CommandExecutionError('weibo user-posts failed without an error message');
}
if (/login|cookie|登录|auth|forbidden|permission|权限|unauthorized/i.test(message)) {
throw new AuthRequiredError('weibo.com', message);
}
throw new CommandExecutionError(message);
}
export const testInternals = {
readRequiredId,
readLimit,
readDate,
dateToTimestamp,
};
cli({
site: 'weibo',
name: 'user-posts',
access: 'read',
description: 'List Weibo posts from a user, optionally filtered by date range',
domain: 'weibo.com',
strategy: Strategy.COOKIE,View on GitHub (pinned to 49907e53dc)
Solutions
- Log in to weibo.com and export/refresh the cookies used by the CLI.
- Verify the cookie file/env configuration the command reads points to the current session's cookies.
- Re-run after refreshing; if it persists, check for IP-based blocking or login-wall changes.
- Confirm you are logged into the account whose posts you are querying.
Defensive patterns
Strategy: try-catch
Validate before calling
import { existsSync, statSync } from 'node:fs';
if (!existsSync(cookiePath) || Date.now() - statSync(cookiePath).mtimeMs > 7 * 864e5) {
throw new Error('weibo cookies missing or stale; re-export before running');
} Type guard
function isAuthRequiredError(e) {
return e && e.name === 'AuthRequiredError';
} Try / catch
try {
await runUserPosts(opts);
} catch (err) {
if (err instanceof AuthRequiredError) {
await refreshWeiboCookies(); // re-login and re-export cookies
return runUserPosts(opts);
}
throw err;
} Prevention
- Keep weibo.com session cookies fresh; re-export regularly.
- Log in to the account you query before running batch jobs.
- Watch for Weibo login-wall/anti-bot changes after long idle periods.
When it happens
Trigger: Scraping while not logged in, an expired/invalid weibo.com session cookie, or the page returning a forbidden/permission response during extraction.
Common situations: Cookie configuration missing or stale, cookies expired after Weibo rotates the session, running from an IP/region with stricter login enforcement, or Weibo changing its login wall behavior.
Related errors
- 12306 tk auth cookie missing
- amazon.com
- Bilibili ${label} API requires login or permission: ${messag
- Boss wt2 / t cookies missing
- Waiting for Boss wt2 / t cookies
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/a395778535a4e012.
Report an issue: GitHub.