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
An AuthRequiredError thrown by fetchLinkedInLearningApi when, after loading linkedin.com/learning/, no JSESSIONID cookie exists in the browser context. JSESSIONID is the session cookie the CLI uses to derive the csrf-token for the in-page API fetch, so its absence means the browser has no authenticated LinkedIn session at all.
Source
Thrown at clis/linkedin-learning/shared.js:51
},
});
if (res.status === 401 || res.status === 403) return { authRequired: true, status: res.status };
if (!res.ok) return { error: 'HTTP ' + res.status };
return { json: await res.json() };
} catch (e) {
return { error: 'fetch failed: ' + ((e && e.message) || String(e)) };
}
})()`;
}
export async function fetchLinkedInLearningApi(page, url) {
await page.goto('https://www.linkedin.com/learning/');
await page.wait(3);
const cookies = await page.getCookies({ url: 'https://www.linkedin.com' });
const jsession = cookies.find((c) => c.name === 'JSESSIONID')?.value;
if (!jsession) {
throw new AuthRequiredError(DOMAIN, 'LinkedIn JSESSIONID cookie not found. Please sign in to LinkedIn in the browser.');
}
const csrf = jsession.replace(/^"|"$/g, '');
const result = unwrapEvaluateResult(await page.evaluate(buildFetchScript(url, csrf)));
if (result?.authRequired) {
throw new AuthRequiredError(DOMAIN, `LinkedIn Learning auth failed (HTTP ${result.status ?? ''}).`);
}
return result;
}
View on GitHub (pinned to 49907e53dc)
Solutions
- Open the controlled browser, sign in to LinkedIn manually, then re-run the command.
- Point the CLI at a persistent browser profile that already has an active LinkedIn session.
- Complete any LinkedIn security/2FA challenge that invalidated the session.
- Verify cookies exist: page.getCookies({url:'https://www.linkedin.com'}) should include JSESSIONID before calling the API.
- Avoid incognito/ephemeral contexts; reuse the same user-data-dir each run.
Example fix
// before
const browser = await launch({ headless: true }); // fresh, signed-out context
// after
const browser = await launch({ userDataDir: PROFILE_DIR }); // profile signed in to LinkedIn Defensive patterns
Strategy: try-catch
Validate before calling
// verify session cookies exist before invoking any linkedin-learning command
const cookies = await page.getCookies({ url: 'https://www.linkedin.com' });
if (!cookies.some(c => c.name === 'JSESSIONID')) {
throw new Error('Not signed in to LinkedIn: open the browser and log in first');
} Type guard
function hasLinkedInSession(cookies) {
return Array.isArray(cookies) && cookies.some(c => c.name === 'JSESSIONID' && !!c.value);
} Try / catch
try {
const rows = await trendingOrSearch(page);
} catch (e) {
if (/JSESSIONID cookie not found|AuthRequired/i.test(e.message)) {
await interactiveLogin(page); // open visible browser, wait for manual sign-in
return trendingOrSearch(page);
}
throw e;
} Prevention
- Use a persistent browser profile (userDataDir) that stays signed in
- Sign in to LinkedIn once before batch runs; re-login when sessions expire
- Avoid incognito/ephemeral contexts for LinkedIn automation
- Check for security/2FA prompts that invalidate stored sessions
- Pre-flight check JSESSIONID presence before long automation runs
When it happens
Trigger: The automated/persistent browser profile was never signed in to LinkedIn, the session fully expired and cookies were cleared, the profile directory was reset, or cookies were fetched from a URL context that excludes the session (private window, fresh context).
Common situations: Running the CLI on a new machine/container with an empty browser profile, cookie purging by browser settings or cleanup jobs, LinkedIn forcing a full re-login (password change, security challenge), or launching the browser headless with a fresh context.
Related errors
- Chaoxing session cookies missing
- Claude sessionKey cookie missing
- Claude session incomplete — ajs_user_id cookie missing
- Google session cookies are missing
- linkedin.com: ${result.detail}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/fc63b37305324549.
Report an issue: GitHub.