jackwener/OpenCLI · warning · AuthRequiredError

linkedin.com: Waiting for LinkedIn li_at cookie

Error message

linkedin.com: Waiting for LinkedIn li_at cookie

What it means

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.

Source

Thrown at clis/linkedin-learning/auth.js:58

    }
  })()`);
  if (result?.kind === 'auth') throw new AuthRequiredError('linkedin.com', result.detail);
  if (result?.kind === 'http') throw new CommandExecutionError(`HTTP ${result.httpStatus} from /voyager/api/me`);
  if (result?.kind === 'exception') throw new CommandExecutionError(`LinkedIn Learning whoami failed: ${result.detail}`);
  if (!result?.ok) throw new CommandExecutionError(`Unexpected LinkedIn Learning probe: ${JSON.stringify(result)}`);
  return { public_id: result.public_id, plain_id: result.plain_id, name: result.name };
}

registerSiteAuthCommands({
  site: 'linkedin-learning',
  domain: 'linkedin.com',
  loginUrl: 'https://www.linkedin.com/login?session_redirect=%2Flearning%2F',
  columns: ['public_id', 'plain_id', 'name'],
  quickCheck: hasLinkedinSessionCookie,
  verify: verifyLinkedinLearningIdentity,
  poll: async (page) => {
    if (!await hasLinkedinSessionCookie(page)) {
      throw new AuthRequiredError('linkedin.com', 'Waiting for LinkedIn li_at cookie');
    }
    return verifyLinkedinLearningIdentity(page);
  },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Complete the LinkedIn login in the automation browser at https://www.linkedin.com/login?session_redirect=%2Flearning%2F.
  2. If already logged in but poll keeps failing, check that cookies are set on linkedin.com in the same browser context being polled.
  3. Restart the login flow if the session attempt failed (wrong password / abandoned 2FA).
  4. Ensure cookies aren't being blocked (third-party cookie settings, fresh incognito profile) in the automation browser.

Example fix

// before
// poll loop spams 'Waiting for LinkedIn li_at cookie'
// after
// finish login first, then poll succeeds
await page.goto('https://www.linkedin.com/login?session_redirect=%2Flearning%2F');
await loginAndComplete2FA(page); // then poll returns verifyLinkedinLearningIdentity(page)
Defensive patterns

Strategy: try-catch

Validate before calling

const cookies = await page.getCookies({ url: 'https://www.linkedin.com' });
const ready = cookies.some(c => c.name === 'li_at' && c.value);
if (!ready) await waitForUserLogin(page, { timeoutMs: 300_000 });

Type guard

function isWaitingForLogin(e) { return e?.name === 'AuthRequiredError' && /Waiting for LinkedIn li_at/.test(e.message ?? ''); }

Try / catch

try {
  const identity = await poll(page);
} catch (e) {
  if (isWaitingForLogin(e)) {
    await sleep(2_000); // keep polling until user finishes login
    return poll(page);
  }
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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