jackwener/OpenCLI · error · AuthRequiredError

Bilibili creator-center login is required: ${message}

Error message

Bilibili creator-center login is required: ${message}

What it means

When the comparison endpoint returns a well-formed envelope whose `code` is non-zero and isAuthLike() matches (code -101/-111, or a message containing 登录/账号未登录/login required/not logged in), the library rethrows the condition as AuthRequiredError for member.bilibili.com. This distinguishes 'you are not logged in' from a generic API failure so callers can trigger an interactive login flow.

Source

Thrown at clis/bilibili/creator-stats.js:55

function isRecord(value) {
    return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
}

function isAuthLike(code, message) {
    return code === -101
        || code === -111
        || /登录|账号未登录|login required|not logged in/i.test(String(message ?? ''));
}

function requirePayload(payload) {
    if (!isRecord(payload) || !Number.isSafeInteger(payload.code)) {
        throw new CommandExecutionError('Bilibili creator comparison API returned a malformed envelope');
    }
    const message = String(payload.message ?? payload.msg ?? 'unknown error');
    if (payload.code !== 0) {
        if (isAuthLike(payload.code, message)) {
            throw new AuthRequiredError('member.bilibili.com', `Bilibili creator-center login is required: ${message}`);
        }
        throw new CommandExecutionError(`Bilibili creator comparison API failed: ${message} (${payload.code})`);
    }
    if (!isRecord(payload.data) || !Array.isArray(payload.data.list)) {
        throw new CommandExecutionError('Bilibili creator comparison API returned malformed list data');
    }
    return payload.data.list;
}

async function fetchComparison(page) {
    try {
        const payload = await page.fetchJson(
            `${MEMBER_ORIGIN}/x/web/data/archive_diagnose/compare?size=100`,
            { timeoutMs: FETCH_TIMEOUT_SECONDS * 1000 },
        );
        return requirePayload(payload);
    }
    catch (error) {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Open member.bilibili.com/platform/home in the CLI's browser profile and log in / re-login to refresh the session cookie
  2. Clear bilibili.com cookies and log in again to obtain a fresh SESSDATA
  3. Confirm the logged-in account actually owns creator-center data (the endpoint requires an authenticated creator account)
  4. Complete any security verification (captcha/SMS) Bilibili prompts before retrying

Example fix

// before
$ opencli bilibili creator-stats BV1xx411c7mD
AuthRequiredError: Bilibili creator-center login is required: 账号未登录

// after: re-authenticate in the shared browser profile
$ # log into member.bilibili.com in the browser, then retry:
$ opencli bilibili creator-stats BV1xx411c7mD
Defensive patterns

Strategy: try-catch

Validate before calling

const probe = await fetch('https://member.bilibili.com/x/web/data/archive_diagnose/compare?size=1', { headers: { cookie } });
const body = await probe.json();
if (body?.code === -101 || body?.code === -111 || /登录|not logged in/i.test(body?.message ?? body?.msg ?? '')) {
  throw new Error('Refresh your member.bilibili.com login first');
}

Try / catch

try {
  const rows = await runCommand();
} catch (e) {
  if (e.name === 'AuthRequiredError') {
    // open member.bilibili.com/platform/home for an interactive login, then retry
  } else throw e;
}

Prevention

When it happens

Trigger: fetchJson on the archive_diagnose/compare endpoint returns {code: -101 or -111, message/msg containing 登录 or 'not logged in'} — i.e. the cookie session is missing, expired, or lacks creator-center scope.

Common situations: Browser cookies expired since last login; user logged out of bilibili.com; session cookie not carried into the CLI's Strategy.COOKIE browser profile; account restricted so the creator center demands re-authentication.

Related errors


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