jackwener/OpenCLI · error · AuthRequiredError('web.okjike.com')
${probe.detail}
Error message
${probe.detail} What it means
AuthRequiredError for web.okjike.com thrown by requireJikeIdentity when the in-page identity probe reports kind 'auth': the JK_ACCESS_TOKEN is missing from localStorage, or the users/profile call returned 401/403 or no user object. The library requires a logged-in Jike session before running any identity-bound command.
Source
Thrown at clis/jike/utils.js:30
const token = localStorage.getItem('JK_ACCESS_TOKEN') || '';
if (!token) return { kind: 'auth', detail: 'Jike JK_ACCESS_TOKEN missing from localStorage (anonymous)' };
const r = await fetch('https://api.ruguoapp.com/1.0/users/profile', {
headers: { 'x-jike-access-token': token, Accept: 'application/json' },
});
if (r.status === 401 || r.status === 403) return { kind: 'auth', detail: 'Jike users/profile HTTP ' + r.status };
if (!r.ok) return { kind: 'http', httpStatus: r.status };
const d = await r.json();
const u = d && d.user;
if (!u || !u.id) return { kind: 'auth', detail: 'Jike users/profile returned no user (anonymous)' };
return { ok: true, user_id: String(u.id), screen_name: String(u.screenName || ''), username: String(u.username || '') };
} catch (e) {
return { kind: 'exception', detail: String(e && e.message || e) };
}
})()`;
export async function requireJikeIdentity(page) {
const probe = await page.evaluate(JIKE_IDENTITY_PROBE);
if (probe?.kind === 'auth') throw new AuthRequiredError('web.okjike.com', probe.detail);
if (probe?.kind === 'http') throw new CommandExecutionError(`HTTP ${probe.httpStatus} from Jike users/profile`);
if (probe?.kind === 'exception') throw new CommandExecutionError(`Jike identity probe failed: ${probe.detail}`);
if (!probe?.ok) throw new CommandExecutionError(`Unexpected Jike identity probe: ${JSON.stringify(probe)}`);
return { user_id: probe.user_id, screen_name: probe.screen_name, username: probe.username };
}
export function normalizeJikeLimit(raw, defaultValue = 20) {
const limit = raw ?? defaultValue;
if (!Number.isInteger(limit) || limit < 1) {
throw new ArgumentError('--limit must be a positive integer');
}
return limit;
}
export async function postJikeApi(page, path, requestBody, label) {
const url = `https://api.ruguoapp.com${path}`;
const outcome = await page.evaluate(`(async () => {
const token = localStorage.getItem('JK_ACCESS_TOKEN') || '';View on GitHub (pinned to 49907e53dc)
Solutions
- Log into web.okjike.com in the browser session the CLI drives, then retry
- Verify localStorage JK_ACCESS_TOKEN exists on web.okjike.com; re-login if absent
- If the token exists but returns 401/403, log out and back in to mint a fresh token
- Persist a dedicated browser profile for the CLI so the login survives restarts
Example fix
// before: headless run with no session const identity = await verifyJikeIdentity(page); // throws AuthRequiredError // after: ensure login first await loginJike(page); // opens browser for interactive login const identity = await verifyJikeIdentity(page);
Defensive patterns
Strategy: try-catch
Validate before calling
const token = localStorage.getItem('JK_ACCESS_TOKEN');
if (!token) throw new Error('Log into web.okjike.com before running identity-bound Jike commands'); Type guard
function isIdentity(v) {
return !!v && typeof v === 'object' && typeof v.user_id === 'string' && v.user_id.length > 0;
} Try / catch
try {
const identity = await verifyJikeIdentity(page);
} catch (e) {
if (e.name === 'AuthRequiredError') {
await loginJike(page); // interactive re-login
return verifyJikeIdentity(page);
}
throw e;
} Prevention
- Log into web.okjike.com in the browser profile the CLI uses
- Persist a dedicated profile so sessions survive restarts
- Re-login proactively when tokens age out
- Avoid privacy modes that block localStorage
When it happens
Trigger: Calling verifyJikeIdentity (via requireJikeIdentity) while the browser page is logged out — no JK_ACCESS_TOKEN in localStorage, an expired token rejected with 401/403, or the profile endpoint returning no user for an anonymous session.
Common situations: Fresh browser profile never logged into Jike; token expired after Jike rotated sessions; cookies/localStorage cleared; running in CI where no interactive login exists.
Related errors
- Bilibili creator-center login is required: ${message}
- Bilibili creator-center login is required: ${detail}
- Boss redirected to login page
- ${reason}${detail}
- Sign in to grok.com in the browser, then retry.
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/bf6cb3f5152020e2.
Report an issue: GitHub.