jackwener/OpenCLI · error · AuthRequiredError

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

Error message

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

What it means

Second classification branch in fetchComparison's catch: if the underlying error's message/hint matches /HTTP\s+(401|403)|登录|passport|\/login\b/i, the error is rethrown as AuthRequiredError('member.bilibili.com', ...). This catches HTTP-level 401/403 responses and passport/login redirects that occur before a JSON envelope exists.

Source

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

            { timeoutMs: FETCH_TIMEOUT_SECONDS * 1000 },
        );
        return requirePayload(payload);
    }
    catch (error) {
        if (
            error instanceof AuthRequiredError
            || error instanceof EmptyResultError
            || error instanceof CommandExecutionError
            || error instanceof TimeoutError
        ) {
            throw error;
        }
        const detail = `${error?.message ?? error} ${error?.hint ?? ''}`.trim();
        if (/abort|timed?\s*out|timeout/i.test(detail)) {
            throw new TimeoutError('Bilibili creator comparison', FETCH_TIMEOUT_SECONDS);
        }
        if (/HTTP\s+(401|403)|登录|passport|\/login\b/i.test(detail)) {
            throw new AuthRequiredError('member.bilibili.com', `Bilibili creator-center login is required: ${detail}`);
        }
        throw new CommandExecutionError(`Bilibili creator comparison request failed: ${detail}`);
    }
}

function selectTarget(list, bvid) {
    const matches = [];
    for (const item of list) {
        if (!isRecord(item) || typeof item.bvid !== 'string' || !/^BV[0-9A-Za-z]{10}$/.test(item.bvid)) {
            throw new CommandExecutionError('Bilibili creator comparison returned a malformed manuscript row');
        }
        if (item.bvid === bvid) matches.push(item);
    }
    if (matches.length > 1) {
        throw new CommandExecutionError(`Bilibili creator comparison returned duplicate rows for ${bvid}`);
    }
    if (matches.length === 0) {
        throw new EmptyResultError(

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Log in to member.bilibili.com in the browser profile the CLI uses, then re-run the command
  2. Clear bilibili.com cookies and re-authenticate to obtain a fresh session
  3. Check whether your IP/network is being blocked (403) and try a different network
  4. Verify the CLI browser profile actually retains cookies (not incognito/headless with fresh storage)

Example fix

// before
$ opencli bilibili creator-stats BV1xx411c7mD
AuthRequiredError: Bilibili creator-center login is required: HTTP 403 ... passport.bilibili.com/login

// after: re-login in the shared browser profile, then retry
$ opencli bilibili creator-stats BV1xx411c7mD
Defensive patterns

Strategy: try-catch

Validate before calling

const res = await fetch('https://member.bilibili.com/platform/home', { headers: { cookie }, redirect: 'manual' });
if (res.status === 401 || res.status === 403 || (res.status >= 300 && /passport|login/.test(res.headers.get('location') || ''))) {
  throw new Error('Session expired — re-login to member.bilibili.com first');
}

Try / catch

try {
  const rows = await runCommand();
} catch (e) {
  if (e.name === 'AuthRequiredError') {
    // launch interactive login to member.bilibili.com, then retry once
  } else throw e;
}

Prevention

When it happens

Trigger: page.fetchJson receives an HTTP 401/403 from member.bilibili.com, or is redirected to passport.bilibili.com / a /login URL — session cookie absent, expired, or rejected at the HTTP layer rather than via an API code.

Common situations: Fully expired SESSDATA cookie causing a passport redirect; IP flagged by risk control returning 403; browser profile logged out; corporate proxy stripping cookies.

Related errors


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