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

The command needs the JSESSIONID cookie to authenticate subsequent LinkedIn calls. After extracting cookies it searches for name === 'JSESSIONID'; if absent (or empty value), it throws AuthRequiredError telling the user to sign in to LinkedIn in the controlled browser. This is an auth error, not a code bug.

Source

Thrown at clis/linkedin/people-search.js:213

        try {
            await page.goto(buildSearchUrl(keywords));
            await page.wait(6);
        } catch (error) {
            throw new CommandExecutionError(`LinkedIn people search navigation failed: ${error?.message || error}`);
        }

        let cookies;
        try {
            cookies = await page.getCookies({ url: 'https://www.linkedin.com' });
        } catch (error) {
            throw new CommandExecutionError(`LinkedIn cookie lookup failed: ${error?.message || error}`);
        }
        if (!Array.isArray(cookies)) {
            throw new CommandExecutionError('LinkedIn cookie lookup returned malformed payload');
        }
        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.');
        }

        let result;
        try {
            result = unwrapEvaluateResult(await page.evaluate(extractionScript()));
        } catch (error) {
            throw new CommandExecutionError(`LinkedIn people search extraction failed: ${error?.message || error}`);
        }
        if (result?.error) {
            if (looksLinkedInAuthWall(`${result.url || ''} ${result.error || ''}`)) {
                throw new AuthRequiredError(LINKEDIN_DOMAIN, 'LinkedIn people search requires an active signed-in browser session.');
            }
            // If LinkedIn redirected away from the search page that
            // usually means CUL was reached or the account is gated.
            throw new CommandExecutionError(`LinkedIn redirected away from the search page (${result.error}). Likely Commercial Use Limit reached - the limit resets on the 1st of next month.`);
        }
        if (!result || typeof result !== 'object') {
            throw new CommandExecutionError('LinkedIn people search returned malformed extraction payload');

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Open the controlled browser, sign in to LinkedIn manually, then re-run the command
  2. Export/import a browser profile that already has an active LinkedIn session
  3. Verify JSESSIONID exists (DevTools > Application > Cookies on linkedin.com) before running
  4. Catch AuthRequiredError in your tooling and prompt the user to authenticate

Example fix

// before
await cli('linkedin people-search', { keywords: 'sre berlin' });
// after: ensure session first
await cli('browser open'); // then sign in to linkedin.com interactively
await cli('linkedin people-search', { keywords: 'sre berlin' });
Defensive patterns

Strategy: validation

Validate before calling

const cookies = await page.getCookies({ url: 'https://www.linkedin.com' });
if (!cookies.some((c) => c.name === 'JSESSIONID' && c.value)) {
  throw new Error('Not signed in to LinkedIn: open the browser and log in first');
}

Type guard

const hasLinkedInSession = (cookies) => Array.isArray(cookies) &&
  cookies.some((c) => c.name === 'JSESSIONID' && Boolean(c.value));

Try / catch

try { await cli('linkedin people-search', args); }
catch (e) { if (e.name === 'AuthRequiredError' || /JSESSIONID/.test(e.message)) { await promptLinkedInLogin(); return retry(); } throw e; }

Prevention

When it happens

Trigger: Browser session exists and cookies were read successfully, but no JSESSIONID cookie is present for https://www.linkedin.com — the user never logged in, the session expired, LinkedIn set a logged-out cookie set, or cookies were cleared.

Common situations: Fresh browser profile with no LinkedIn login; LinkedIn session expired (weeks-old profile); using a cookie jar / incognito profile that does not persist login; logged out manually before running the command; corporate environment blocking linkedin.com session cookies.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/b1e6062241451832. Report an issue: GitHub.