{"record":{"id":"66b5f77022c88296","repo":"jackwener/OpenCLI","slug":"waiting-for-claude-sessionkey-cookie","errorCode":null,"errorMessage":"Waiting for Claude sessionKey cookie","messagePattern":"Waiting for Claude sessionKey cookie","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"warning","filePath":"clis/claude/auth.js","lineNumber":51,"sourceCode":"  })()`);\n  if (result?.kind === 'auth') throw new AuthRequiredError('claude.ai', result.detail);\n  if (result?.kind === 'http') throw new CommandExecutionError(`HTTP ${result.httpStatus} from /api/organizations`);\n  if (result?.kind === 'exception') throw new CommandExecutionError(`Claude whoami failed: ${result.detail}`);\n  if (!result?.ok) throw new CommandExecutionError(`Unexpected Claude probe: ${JSON.stringify(result)}`);\n  if (!result.user_id) throw new AuthRequiredError('claude.ai', 'Claude session incomplete — ajs_user_id cookie missing');\n  return { user_id: String(result.user_id), org_name: String(result.org_name), org_uuid: String(result.org_uuid) };\n}\n\nregisterSiteAuthCommands({\n  site: 'claude',\n  domain: 'claude.ai',\n  loginUrl: 'https://claude.ai/login',\n  columns: ['user_id', 'org_name', 'org_uuid'],\n  quickCheck: hasClaudeSessionCookie,\n  verify: verifyClaudeIdentity,\n  poll: async (page) => {\n    if (!await hasClaudeSessionCookie(page)) {\n      throw new AuthRequiredError('claude.ai', 'Waiting for Claude sessionKey cookie');\n    }\n    return verifyClaudeIdentity(page);\n  },\n});\n","sourceCodeStart":33,"sourceCodeEnd":56,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/claude/auth.js#L33-L56","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Complete the login in the opened browser window (including any email-code/SSO steps) before the poll timeout expires","If login failed, retry `opencli claude auth` and enter valid credentials","Check the browser window for a Cloudflare challenge or 2FA prompt that must be solved manually","If you use SSO, ensure the SSO session is valid; complete that flow fully so sessionKey gets set","If the poll times out repeatedly, extend the auth command's timeout or update the library if Claude changed its cookie name"],"exampleFix":"// before\n// poll: 'Waiting for Claude sessionKey cookie' ... timeout\n// after\n// finish login in the automated browser, or rerun:\nopencli claude auth   // complete full login including email code, then whoami succeeds","handlingStrategy":"retry","validationCode":"null","typeGuard":"null","tryCatchPattern":"try {\n  await pollForLogin(page);\n} catch (e) {\n  if (e.message === 'Waiting for Claude sessionKey cookie') {\n    // keep polling / prompt the user to finish login in the browser window\n    console.log('Finish logging in to claude.ai in the automated browser...');\n  }\n  throw e;\n}","preventionTips":["Complete the entire login (email code, SSO, 2FA) in the automated browser before the poll timeout","Watch the automated browser window during the auth flow","Pre-check with a quick cookie check that sessionKey is set before running commands","Allow extra time for slow email-code delivery"],"tags":["auth","cookies","claude","login-polling"],"backgroundTag":"waiting-for-session-cookie","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}