jackwener/OpenCLI · error · AuthRequiredError
LinkedIn requires an active signed-in browser session.
Error message
LinkedIn requires an active signed-in browser session.
What it means
After loading LinkedIn messaging in the automated browser, the CLI inspects the page for the messaging API request URL. When the page reports loginRequired, it means LinkedIn redirected to a login page / did not see an authenticated session, so an AuthRequiredError is thrown naming the LinkedIn domain. The library cannot read the inbox without a signed-in browser profile.
Source
Thrown at clis/linkedin/inbox.js:173
func: async (page, kwargs) => {
// Validate --limit explicitly rather than silently clamping an out-of-range value.
let limit = DEFAULT_LIMIT;
if (kwargs.limit !== undefined && kwargs.limit !== null && kwargs.limit !== '') {
limit = Number(kwargs.limit);
if (!Number.isInteger(limit) || limit < MIN_LIMIT || limit > MAX_LIMIT) {
throw new ArgumentError(`--limit must be an integer between ${MIN_LIMIT} and ${MAX_LIMIT}`);
}
}
const unreadOnly = Boolean(kwargs['unread-only']);
await page.goto(MESSAGING_URL);
await page.wait(10);
// Locate the messaging API request the page fired on load; retry once if the
// SPA was slow to issue it.
let located = unwrapEvaluateResult(await page.evaluate(`(${findMessagingApiUrl.toString()})()`));
if (located && located.loginRequired) {
throw new AuthRequiredError(LINKEDIN_DOMAIN, 'LinkedIn requires an active signed-in browser session.');
}
if (!located || !located.url) {
await page.wait(6);
located = unwrapEvaluateResult(await page.evaluate(`(${findMessagingApiUrl.toString()})()`));
}
if (!located || !located.url) {
throw new CommandExecutionError(
'LinkedIn did not issue a messaging API request; the inbox may have failed to load.',
);
}
const cookies = await page.getCookies({ url: 'https://www.linkedin.com' });
const jsession = cookies.find((c) => c.name === 'JSESSIONID')?.value;
if (!jsession) {
throw new AuthRequiredError(LINKEDIN_DOMAIN, 'LinkedIn JSESSIONID cookie not found. Please sign in to LinkedIn.');
}
const csrf = jsession.replace(/^"|"$/g, '');
View on GitHub (pinned to 49907e53dc)
Solutions
- Open the browser profile used by the CLI and sign in to LinkedIn manually, then re-run the command.
- Verify the session is alive by loading https://www.linkedin.com/feed/ in that profile; if redirected to login, re-authenticate.
- Ensure the profile persists cookies between runs (not incognito/ephemeral storage) so JSESSIONID/li_at survive.
Example fix
// before: headless run with a throwaway profile
await runCli('linkedin inbox'); // AuthRequiredError
// after: sign in once in the persistent profile, then
await runCli('linkedin inbox'); // works while session is valid Defensive patterns
Strategy: try-catch
Validate before calling
async function hasLinkedinSession(page) {
await page.goto('https://www.linkedin.com/feed/');
return !/login|signin/i.test(page.url());
}
// call before running the inbox command Type guard
const isAuthRequiredError = (e) => e instanceof AuthRequiredError || /signed-in|sign in|login/i.test(e?.message || '');
Try / catch
try {
await linkedinInbox();
} catch (e) {
if (isAuthRequiredError(e)) {
await openBrowserForManualLogin(LINKEDIN_DOMAIN);
return linkedinInbox();
}
throw e;
} Prevention
- Use a persistent browser profile so LinkedIn cookies survive restarts.
- Check session validity (feed loads without redirect) before scheduled runs.
- Re-authenticate proactively when li_at/JSESSIONID age exceeds your observed session lifetime.
- Avoid incognito/ephemeral contexts for authenticated commands.
When it happens
Trigger: Calling `linkedin inbox` while the controlled browser has no valid LinkedIn session: findMessagingApiUrl() returns { loginRequired: true }, typically because messaging redirects to the auth wall on load.
Common situations: Expired LinkedIn session cookies, running with a fresh/incognito browser profile that was never signed in, LinkedIn forcing re-authentication after a security event, or using a headless profile without persisted login state.
Related errors
- LinkedIn sent-invitations verification requires an active si
- LinkedIn JSESSIONID cookie not found. Please sign in to Link
- LinkedIn sent invitations requires an active signed-in brows
- Browser session required for bilibili subtitle
- Browser session required for bilibili summary
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/aa2e330ec941f6aa.
Report an issue: GitHub.