{"record":{"id":"2104414732e0ce73","repo":"jackwener/OpenCLI","slug":"linkedin-com-waiting-for-linkedin-li-at-cookie","errorCode":null,"errorMessage":"linkedin.com: Waiting for LinkedIn li_at cookie","messagePattern":"linkedin\\.com: Waiting for LinkedIn li_at cookie","errorType":"error_code","errorClass":"AuthRequiredError","httpStatus":null,"severity":"warning","filePath":"clis/linkedin-learning/auth.js","lineNumber":58,"sourceCode":"    }\n  })()`);\n  if (result?.kind === 'auth') throw new AuthRequiredError('linkedin.com', result.detail);\n  if (result?.kind === 'http') throw new CommandExecutionError(`HTTP ${result.httpStatus} from /voyager/api/me`);\n  if (result?.kind === 'exception') throw new CommandExecutionError(`LinkedIn Learning whoami failed: ${result.detail}`);\n  if (!result?.ok) throw new CommandExecutionError(`Unexpected LinkedIn Learning probe: ${JSON.stringify(result)}`);\n  return { public_id: result.public_id, plain_id: result.plain_id, name: result.name };\n}\n\nregisterSiteAuthCommands({\n  site: 'linkedin-learning',\n  domain: 'linkedin.com',\n  loginUrl: 'https://www.linkedin.com/login?session_redirect=%2Flearning%2F',\n  columns: ['public_id', 'plain_id', 'name'],\n  quickCheck: hasLinkedinSessionCookie,\n  verify: verifyLinkedinLearningIdentity,\n  poll: async (page) => {\n    if (!await hasLinkedinSessionCookie(page)) {\n      throw new AuthRequiredError('linkedin.com', 'Waiting for LinkedIn li_at cookie');\n    }\n    return verifyLinkedinLearningIdentity(page);\n  },\n});\n","sourceCodeStart":40,"sourceCodeEnd":63,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/linkedin-learning/auth.js#L40-L63","documentation":"The poll handler registered for the linkedin-learning site re-checks for the li_at session cookie before verifying identity. While the user is going through the interactive login flow and the cookie has not yet appeared, polling throws AuthRequiredError 'Waiting for LinkedIn li_at cookie'. It's the polling-loop signal that login is not yet complete, not a hard failure of a verified session.","triggerScenarios":"poll(page) invoked during the interactive login wait loop while hasLinkedinSessionCookie(page) is still false — the user hasn't finished LinkedIn login yet, or the login didn't set li_at.","commonSituations":"User slow to complete login or closed the login tab; login failed (wrong credentials, 2FA abandoned); LinkedIn set cookies on a different domain than expected; automation browser profile not persisting cookies.","solutions":["Complete the LinkedIn login in the automation browser at https://www.linkedin.com/login?session_redirect=%2Flearning%2F.","If already logged in but poll keeps failing, check that cookies are set on linkedin.com in the same browser context being polled.","Restart the login flow if the session attempt failed (wrong password / abandoned 2FA).","Ensure cookies aren't being blocked (third-party cookie settings, fresh incognito profile) in the automation browser."],"exampleFix":"// before\n// poll loop spams 'Waiting for LinkedIn li_at cookie'\n// after\n// finish login first, then poll succeeds\nawait page.goto('https://www.linkedin.com/login?session_redirect=%2Flearning%2F');\nawait loginAndComplete2FA(page); // then poll returns verifyLinkedinLearningIdentity(page)","handlingStrategy":"try-catch","validationCode":"const cookies = await page.getCookies({ url: 'https://www.linkedin.com' });\nconst ready = cookies.some(c => c.name === 'li_at' && c.value);\nif (!ready) await waitForUserLogin(page, { timeoutMs: 300_000 });","typeGuard":"function isWaitingForLogin(e) { return e?.name === 'AuthRequiredError' && /Waiting for LinkedIn li_at/.test(e.message ?? ''); }","tryCatchPattern":"try {\n  const identity = await poll(page);\n} catch (e) {\n  if (isWaitingForLogin(e)) {\n    await sleep(2_000); // keep polling until user finishes login\n    return poll(page);\n  }\n  throw e;\n}","preventionTips":["Keep the login tab open and complete login (including 2FA) before expecting success.","Use a polling loop with a generous timeout instead of a single attempt.","Confirm cookies are written to the same browser context being polled.","Detect failed login attempts and restart the flow instead of polling forever."],"tags":["auth","cookie","polling"],"backgroundTag":"auth-cookie-missing","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}