jackwener/OpenCLI · error · AuthRequiredError

Cookie 已过期!请在当前 Chrome 浏览器中重新登录 Weibo。

Error message

Cookie 已过期!请在当前 Chrome 浏览器中重新登录 Weibo。

What it means

clis/weibo/delete.js:152 throws AuthRequiredError with this message when the in-page delete script reports error==='auth', meaning Weibo treated the request as unauthenticated. The command automates weibo.com through the user's current Chrome session, so it has no credentials of its own — it depends entirely on live login cookies. When those cookies are missing or expired, Weibo redirects/rejects and the CLI surfaces this error telling the user to re-login in Chrome.

Source

Thrown at clis/weibo/delete.js:152

        try {
          verifyBody = await verifyResp.json();
        } catch {
          return { ok: false, error: 'verify_malformed', msg: 'verify returned non-JSON response', id: idstr };
        }
        if (!verifyBody || typeof verifyBody !== 'object') {
          return { ok: false, error: 'verify_malformed', msg: 'verify returned malformed response', id: idstr };
        }
        if (String(verifyBody.idstr || '') === idstr) {
          return { ok: false, error: 'still_exists', id: idstr, mblogid: verifyBody.mblogid || mblogid };
        }
        if (!verifyBody.idstr || verifyBody.ok === 0) {
          return { ok: true, id: idstr, mblogid };
        }
        return { ok: false, error: 'verify_mismatch', msg: 'verify returned a different post id', id: idstr };
      })()
    `)), 'weibo delete');
        if (result.error === 'auth') {
            throw new AuthRequiredError('weibo.com', 'Cookie 已过期!请在当前 Chrome 浏览器中重新登录 Weibo。');
        }
        if (result.error === 'not_found') {
            throw new EmptyResultError('weibo delete', `Post not found for id "${String(result.input ?? raw)}". Verify the post still exists and belongs to the logged-in account.`);
        }
        if (result.error === 'show_http' || result.error === 'destroy_http' || result.error === 'verify_http') {
            throw new CommandExecutionError(`weibo delete: HTTP ${result.status}`);
        }
        if (result.error === 'api' || result.error === 'verify_malformed' || result.error === 'verify_mismatch' || result.error === 'still_exists') {
            throw new CommandExecutionError(`weibo delete: ${String(result.msg ?? result.error)}`);
        }
        if (!result.ok) {
            throw new CommandExecutionError('weibo delete returned an unexpected response');
        }
        return [{ status: 'deleted', id: String(result.id ?? ''), mblogid: String(result.mblogid ?? '') }];
    },
});

export const __test__ = {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Open weibo.com in the current Chrome browser and log in manually, then retry the command
  2. Verify the Chrome profile the CLI attaches to is the one that is logged in (not a fresh/clean profile)
  3. If login keeps failing, clear weibo.com cookies and log in again, completing any SMS/QR security verification
  4. Avoid changing the account password right before use, which invalidates existing sessions

Example fix

// before: failing run
$ opencli weibo delete 51aBcDeFgH
AuthRequiredError: Cookie 已过期!请在当前 Chrome 浏览器中重新登录 Weibo。
// after: re-login then retry
1. chrome -> weibo.com -> log in
2. $ opencli weibo delete 51aBcDeFgH  // succeeds
Defensive patterns

Strategy: try-catch

Validate before calling

// best-effort pre-check: cannot inspect Chrome cookies from Node; validate input instead
if (!id || !/^[A-Za-z0-9]{4,32}$/.test(String(id).trim())) throw new Error('invalid weibo post id');

Type guard

function isAuthRequiredError(e) { return e instanceof Error && /重新登录|AuthRequired/i.test(e.message); }

Try / catch

try {
  await cli.run('weibo delete', { id });
} catch (e) {
  if (isAuthRequiredError(e)) {
    console.error('Login to weibo.com in Chrome, then retry.');
    process.exitCode = 2; // distinct auth exit code
  } else throw e;
}

Prevention

When it happens

Trigger: Running `weibo delete <id|url>` when the Chrome profile's weibo.com session cookie has expired or the user is logged out; result.error from the evaluate() script is exactly 'auth'.

Common situations: Chrome cookies expired after Weibo's session timeout (typically days-weeks); user logged out of weibo.com or logged into a different account; running the CLI from a headless/CI environment where the Chrome profile was never logged in; Weibo invalidating sessions after a security prompt or password change.

Related errors


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