{"record":{"id":"aa2e330ec941f6aa","repo":"jackwener/OpenCLI","slug":"linkedin-requires-an-active-signed-in-browser-sess","errorCode":null,"errorMessage":"LinkedIn requires an active signed-in browser session.","messagePattern":"LinkedIn requires an active signed-in browser session\\.","errorType":"error_code","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/linkedin/inbox.js","lineNumber":173,"sourceCode":"  func: async (page, kwargs) => {\n    // Validate --limit explicitly rather than silently clamping an out-of-range value.\n    let limit = DEFAULT_LIMIT;\n    if (kwargs.limit !== undefined && kwargs.limit !== null && kwargs.limit !== '') {\n      limit = Number(kwargs.limit);\n      if (!Number.isInteger(limit) || limit < MIN_LIMIT || limit > MAX_LIMIT) {\n        throw new ArgumentError(`--limit must be an integer between ${MIN_LIMIT} and ${MAX_LIMIT}`);\n      }\n    }\n    const unreadOnly = Boolean(kwargs['unread-only']);\n\n    await page.goto(MESSAGING_URL);\n    await page.wait(10);\n\n    // Locate the messaging API request the page fired on load; retry once if the\n    // SPA was slow to issue it.\n    let located = unwrapEvaluateResult(await page.evaluate(`(${findMessagingApiUrl.toString()})()`));\n    if (located && located.loginRequired) {\n      throw new AuthRequiredError(LINKEDIN_DOMAIN, 'LinkedIn requires an active signed-in browser session.');\n    }\n    if (!located || !located.url) {\n      await page.wait(6);\n      located = unwrapEvaluateResult(await page.evaluate(`(${findMessagingApiUrl.toString()})()`));\n    }\n    if (!located || !located.url) {\n      throw new CommandExecutionError(\n        'LinkedIn did not issue a messaging API request; the inbox may have failed to load.',\n      );\n    }\n\n    const cookies = await page.getCookies({ url: 'https://www.linkedin.com' });\n    const jsession = cookies.find((c) => c.name === 'JSESSIONID')?.value;\n    if (!jsession) {\n      throw new AuthRequiredError(LINKEDIN_DOMAIN, 'LinkedIn JSESSIONID cookie not found. Please sign in to LinkedIn.');\n    }\n    const csrf = jsession.replace(/^\"|\"$/g, '');\n","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/linkedin/inbox.js#L155-L191","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: headless run with a throwaway profile\nawait runCli('linkedin inbox'); // AuthRequiredError\n\n// after: sign in once in the persistent profile, then\nawait runCli('linkedin inbox'); // works while session is valid","handlingStrategy":"try-catch","validationCode":"async function hasLinkedinSession(page) {\n  await page.goto('https://www.linkedin.com/feed/');\n  return !/login|signin/i.test(page.url());\n}\n// call before running the inbox command","typeGuard":"const isAuthRequiredError = (e) => e instanceof AuthRequiredError || /signed-in|sign in|login/i.test(e?.message || '');","tryCatchPattern":"try {\n  await linkedinInbox();\n} catch (e) {\n  if (isAuthRequiredError(e)) {\n    await openBrowserForManualLogin(LINKEDIN_DOMAIN);\n    return linkedinInbox();\n  }\n  throw e;\n}","preventionTips":["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."],"tags":["authentication","linkedin","browser-session"],"backgroundTag":"auth-required-session-expired","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}