jackwener/OpenCLI · error · AuthRequiredError

linkedin.com: ${result.detail}

Error message

linkedin.com: ${result.detail}

What it means

The in-page whoami probe against LinkedIn's /voyager/api/me returns { kind: 'auth', detail } when LinkedIn signals the Learning session is not authorized (login redirect / CSRF/auth failure inside the page). The command converts that into AuthRequiredError with the page-reported detail. Unlike 2252, a li_at cookie exists but the Learning session is still not accepted.

Source

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

      if (!res.ok) return { kind: 'http', httpStatus: res.status };
      const d = await res.json();
      const mini = d && d.miniProfile;
      if (!mini || !mini.publicIdentifier) {
        return { kind: 'auth', detail: 'LinkedIn /voyager/api/me 200 but miniProfile missing' };
      }
      const firstName = (mini.firstName && (mini.firstName.text || mini.firstName)) || '';
      const lastName = (mini.lastName && (mini.lastName.text || mini.lastName)) || '';
      return {
        ok: true,
        public_id: String(mini.publicIdentifier),
        plain_id: String(d.plainId || ''),
        name: String((firstName + ' ' + lastName).trim()),
      };
    } catch (e) {
      return { kind: 'exception', detail: String(e && e.message || e) };
    }
  })()`);
  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. Re-run the login flow and make sure you land on https://www.linkedin.com/learning/ logged-in.
  2. Open /learning/ in the automation browser and confirm the Learning UI shows your account.
  3. Clear cookies and log in fresh — a stale li_at can pass the cookie check but fail Voyager auth.
  4. Check the result.detail message for LinkedIn's specific reason (redirect vs 401) and act accordingly.

Example fix

// before
// probe returns {kind:'auth', detail:'login redirect'} — command aborts
// after
await page.goto('https://www.linkedin.com/learning/'); // re-establish Learning session
await runCommand('linkedin-learning login'); // then retry whoami
Defensive patterns

Strategy: try-catch

Validate before calling

// Confirm the Learning UI is actually logged in before probing
await page.goto('https://www.linkedin.com/learning/');
const loggedIn = await page.evaluate(() => !!document.querySelector('[data-li-session], .nav__me, a[href*="/learning/checklist"]'));
if (!loggedIn) await runInteractiveLogin('linkedin-learning');

Type guard

function isAuthFailure(result) { return result?.kind === 'auth' && typeof result.detail === 'string'; }

Try / catch

try {
  const identity = await verifyLinkedinLearningIdentity(page);
} catch (e) {
  if (e.name === 'AuthRequiredError') {
    // li_at exists but Learning session not accepted: re-login on /learning/
    await page.goto('https://www.linkedin.com/learning/');
    await runInteractiveLogin('linkedin-learning');
    return verifyLinkedinLearningIdentity(page);
  }
  throw e;
}

Prevention

When it happens

Trigger: page.evaluate probe returns kind:'auth' — LinkedIn /voyager/api/me responds with a redirect-to-login or 401/403-style auth failure despite li_at being present.

Common situations: li_at cookie valid for linkedin.com but LinkedIn Learning entitlement/session not established; LinkedIn changing Voyager API auth requirements; partial login (main site only); corporate SSO requiring re-auth for Learning.

Related errors


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