jackwener/OpenCLI · error · AuthRequiredError
LinkedIn JSESSIONID cookie not found. Please sign in to Link
Error message
LinkedIn JSESSIONID cookie not found. Please sign in to LinkedIn.
What it means
After locating the messaging API request, the CLI reads the JSESSIONID cookie from the linkedin.com cookie jar to build the CSRF token (csrf). If no JSESSIONID cookie exists, an AuthRequiredError is thrown because API calls from the page context cannot succeed without it. This is a second, cookie-level authentication check on top of the page-level login check.
Source
Thrown at clis/linkedin/inbox.js:188
// 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, '');
// Widen the page size to the requested limit where the query supports it.
const targetUrl = located.url.replace(/count:\d+/, 'count:' + limit);
const fetched = unwrapEvaluateResult(
await page.evaluate(`(${fetchMessagingApi.toString()})(${JSON.stringify(targetUrl)}, ${JSON.stringify(csrf)})`),
);
if (fetched && fetched.authRequired) {
throw new AuthRequiredError(LINKEDIN_DOMAIN, 'LinkedIn messaging API authentication failed: ' + fetched.error);
}
if (!fetched || fetched.error || !fetched.json) {
throw new CommandExecutionError(
'LinkedIn messaging API returned an unexpected response: ' + ((fetched && fetched.error) || 'no data'),
);
}
let conversations = parseConversations(fetched.json, located.mailboxUrn || '');View on GitHub (pinned to 49907e53dc)
Solutions
- Sign in to LinkedIn in the automated browser profile and re-run the command.
- Verify JSESSIONID exists: document.cookie via devtools (or the profile's cookie store) for linkedin.com.
- Disable cookie-clearing extensions or 'clear cookies on exit' settings for the profile.
- Re-login if LinkedIn invalidated the session (e.g. password change, security challenge).
Example fix
// before: profile cookies were wiped between runs
run('linkedin inbox'); // AuthRequiredError: JSESSIONID not found
// after: keep a persistent profile and validate session first
if (!hasLinkedinSession(profile)) openBrowserForManualLogin(profile);
run('linkedin inbox'); Defensive patterns
Strategy: type-guard
Validate before calling
const cookies = await page.getCookies({ url: 'https://www.linkedin.com' });
if (!cookies.some((c) => c.name === 'JSESSIONID')) {
throw new AuthRequiredError('linkedin.com', 'Sign in before running this command.');
} Type guard
const hasJsessionid = (cookies) => Array.isArray(cookies) && cookies.some((c) => c.name === 'JSESSIONID' && c.value);
Try / catch
try {
await linkedinInbox();
} catch (e) {
if (e instanceof AuthRequiredError && /JSESSIONID/.test(e.message)) {
await reloginLinkedin(profile);
return linkedinInbox();
}
throw e;
} Prevention
- Disable 'clear cookies on exit' and cookie-clearing extensions for the automation profile.
- Probe for JSESSIONID before long batch jobs and re-login when absent.
- Keep the browser profile on disk (not tmpfs) so cookies persist across reboots.
- Watch for LinkedIn session invalidation events (password change, new-device challenge) in your ops runbook.
When it happens
Trigger: page.getCookies({ url: 'https://www.linkedin.com' }) contains no cookie named JSESSIONID when processing `linkedin inbox` — the authenticated-page check (2321) passed but the session cookie is absent.
Common situations: Cookie cleared by the browser or an extension, session freshly downgraded (logged out in another tab), HttpOnly/secure cookie scope changes, or pointing getCookies at a URL whose cookie scope excludes the session cookie.
Related errors
- LinkedIn JSESSIONID cookie not found. Please sign in to Link
- 12306 tk auth cookie missing
- csrftoken cookie missing - make sure you are logged in to In
- csrftoken cookie missing - make sure you are logged in to In
- LinkedIn sent-invitations verification requires an active si
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/8a110b47e5f072be.
Report an issue: GitHub.