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 in the browser.
What it means
fetchJobCards reads the browser's cookies for linkedin.com (via CDP getCookies) to obtain JSESSIONID, which doubles as the CSRF token for LinkedIn's internal Voyager API. If no JSESSIONID cookie exists in the browser profile, the command cannot make authenticated API calls and throws this AuthRequiredError telling the user to sign in to LinkedIn in the browser.
Source
Thrown at clis/linkedin/search.js:252
ids.add(id);
else
unresolved.push(name);
}
if (unresolved.length) {
throw new ArgumentError(`Could not resolve LinkedIn company filter: ${unresolved.join(', ')}`);
}
return [...ids];
}
// ── Voyager API fetch (runs inside page context for cookie access) ────
async function fetchJobCards(page, input) {
const MAX_BATCH = 25;
const allJobs = [];
let offset = input.start;
// Read JSESSIONID directly from the cookie store via CDP — zero page.evaluate round-trip
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 in the browser.');
}
const csrf = jsession.replace(/^"|"$/g, '');
while (allJobs.length < input.limit) {
const count = Math.min(MAX_BATCH, input.limit - allJobs.length);
const apiPath = buildVoyagerUrl(input, offset, count);
const batch = await page.evaluate(`(async () => {
const res = await fetch(${JSON.stringify(apiPath)}, {
credentials: 'include',
headers: { 'csrf-token': ${JSON.stringify(csrf)}, 'x-restli-protocol-version': '2.0.0' },
});
if (res.status === 401 || res.status === 403) {
const text = await res.text();
return {
authRequired: true,
error: 'LinkedIn API authentication failed: HTTP ' + res.status + ' ' + text.slice(0, 200)
};
}
if (!res.ok) {View on GitHub (pinned to 49907e53dc)
Solutions
- Open the browser profile used by the CLI, navigate to linkedin.com, and sign in manually, then re-run the command.
- Verify the command is using the intended browser profile/directory (one that actually contains the LinkedIn session).
- Check that cookies are not being cleared between runs (avoid incognito or aggressive cleanup); confirm JSESSIONID exists via the browser devtools cookie panel.
- If LinkedIn is repeatedly dropping the session, reduce request frequency and keep the profile persistent so cookies survive.
Example fix
// before (headless run with fresh profile — no session)
await cli.run(['linkedin', 'search', 'nodejs']);
// after — sign in once in the persistent profile first
await page.goto('https://www.linkedin.com/login');
// ...complete manual login, then:
await cli.run(['linkedin', 'search', 'nodejs']); Defensive patterns
Strategy: try-catch
Validate before calling
// Check the automation browser actually has a LinkedIn session before running
const cookies = await context.cookies('https://www.linkedin.com');
const hasSession = cookies.some(c => c.name === 'JSESSIONID' && c.value);
if (!hasSession) {
console.error('Sign in to LinkedIn in the automation browser profile first.');
process.exit(2);
} Type guard
const hasLinkedInSession = (cookies) => Array.isArray(cookies) && cookies.some(c => c?.name === 'JSESSIONID' && typeof c.value === 'string' && c.value.length > 0);
Try / catch
try {
const jobs = await run(['linkedin', 'search', 'nodejs']);
} catch (e) {
if (/JSESSIONID cookie not found/.test(e.message) || e.name === 'AuthRequiredError') {
console.error('Open the browser profile, sign in to linkedin.com, then retry.');
process.exit(2); // auth-class failure, not a bug
}
throw e;
} Prevention
- Use a persistent browser profile and sign in to LinkedIn once manually before automating.
- Never run LinkedIn commands from incognito or cookie-clearing profiles.
- Re-check session validity periodically; long-lived sessions can still be invalidated server-side.
- Keep automation frequency low so LinkedIn does not proactively expire the session.
When it happens
Trigger: Running `opencli linkedin search <query>` with a browser profile that has no linkedin.com session: never logged in, logged out, cookies cleared, or the wrong/empty browser profile was launched (Strategy.COOKIE mode).
Common situations: Fresh automation profile with no manual login; cookies expired or LinkedIn invalidated the session; running in CI/headless where no one signed in; cookie clearing tools or incognito mode wiping JSESSIONID between runs; multiple browser profiles and the CLI picked one without LinkedIn cookies.
Related errors
- LinkedIn sent-invitations verification requires an active si
- 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
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/4e0cbce2824a5e4c.
Report an issue: GitHub.