jackwener/OpenCLI · warning · AuthRequiredError

Waiting for Claude sessionKey cookie

Error message

Waiting for Claude sessionKey cookie

What it means

During the browser-login polling loop (registerSiteAuthCommands poll callback), this AuthRequiredError is thrown each poll cycle while the claude.ai sessionKey cookie has not yet appeared. It is the library's way of signaling 'login not finished yet' so the poller keeps waiting until the user completes login in the automated browser.

Source

Thrown at clis/claude/auth.js:51

  })()`);
  if (result?.kind === 'auth') throw new AuthRequiredError('claude.ai', result.detail);
  if (result?.kind === 'http') throw new CommandExecutionError(`HTTP ${result.httpStatus} from /api/organizations`);
  if (result?.kind === 'exception') throw new CommandExecutionError(`Claude whoami failed: ${result.detail}`);
  if (!result?.ok) throw new CommandExecutionError(`Unexpected Claude probe: ${JSON.stringify(result)}`);
  if (!result.user_id) throw new AuthRequiredError('claude.ai', 'Claude session incomplete — ajs_user_id cookie missing');
  return { user_id: String(result.user_id), org_name: String(result.org_name), org_uuid: String(result.org_uuid) };
}

registerSiteAuthCommands({
  site: 'claude',
  domain: 'claude.ai',
  loginUrl: 'https://claude.ai/login',
  columns: ['user_id', 'org_name', 'org_uuid'],
  quickCheck: hasClaudeSessionCookie,
  verify: verifyClaudeIdentity,
  poll: async (page) => {
    if (!await hasClaudeSessionCookie(page)) {
      throw new AuthRequiredError('claude.ai', 'Waiting for Claude sessionKey cookie');
    }
    return verifyClaudeIdentity(page);
  },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Complete the login in the opened browser window (including any email-code/SSO steps) before the poll timeout expires
  2. If login failed, retry `opencli claude auth` and enter valid credentials
  3. Check the browser window for a Cloudflare challenge or 2FA prompt that must be solved manually
  4. If you use SSO, ensure the SSO session is valid; complete that flow fully so sessionKey gets set
  5. If the poll times out repeatedly, extend the auth command's timeout or update the library if Claude changed its cookie name

Example fix

// before
// poll: 'Waiting for Claude sessionKey cookie' ... timeout
// after
// finish login in the automated browser, or rerun:
opencli claude auth   // complete full login including email code, then whoami succeeds
Defensive patterns

Strategy: retry

Validate before calling

null

Type guard

null

Try / catch

try {
  await pollForLogin(page);
} catch (e) {
  if (e.message === 'Waiting for Claude sessionKey cookie') {
    // keep polling / prompt the user to finish login in the browser window
    console.log('Finish logging in to claude.ai in the automated browser...');
  }
  throw e;
}

Prevention

When it happens

Trigger: The poll callback runs and hasClaudeSessionCookie(page) finds no non-empty sessionKey cookie for https://claude.ai — the user has not finished (or has abandoned) the login flow, entered wrong credentials, or login failed silently.

Common situations: User not completing the login in the opened browser window before timeout; Claude login flow changed (SSO, email-code step) so sessionKey is set later than expected; login attempt rejected; user closed the browser before finishing; slow email verification code delivery.

Related errors


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