{"record":{"id":"8483e8633f51f6de","repo":"jackwener/OpenCLI","slug":"waiting-for-kimi-auth-cookies","errorCode":null,"errorMessage":"Waiting for Kimi auth cookies","messagePattern":"Waiting for Kimi auth cookies","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"info","filePath":"clis/kimi/auth.js","lineNumber":53,"sourceCode":"    }\n  })()`);\n  if (result?.kind === 'auth') throw new AuthRequiredError('kimi.com', result.detail);\n  if (result?.kind === 'http') throw new CommandExecutionError(`HTTP ${result.httpStatus} from /api/user`);\n  if (result?.kind === 'exception') throw new CommandExecutionError(`Kimi whoami failed: ${result.detail}`);\n  if (!result?.ok) throw new CommandExecutionError(`Unexpected Kimi probe: ${JSON.stringify(result)}`);\n  return { user_id: result.user_id, name: result.name };\n}\n\nregisterSiteAuthCommands({\n  site: 'kimi',\n  domain: 'kimi.com',\n  loginUrl: 'https://www.kimi.com/',\n  columns: ['user_id', 'name'],\n  quickCheck: hasKimiSessionCookie,\n  verify: verifyKimiIdentity,\n  poll: async (page) => {\n    if (!await hasKimiSessionCookie(page)) {\n      throw new AuthRequiredError('kimi.com', 'Waiting for Kimi auth cookies');\n    }\n    return verifyKimiIdentity(page);\n  },\n});\n","sourceCodeStart":35,"sourceCodeEnd":58,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/kimi/auth.js#L35-L58","documentation":"During interactive login polling, the poll function first checks hasKimiSessionCookie; if the access_token cookie has not appeared yet, it throws AuthRequiredError('Waiting for Kimi auth cookies') so the login flow keeps polling until the user completes sign-in. It is a progress signal during `kimi login`, not a hard failure of an API call.","triggerScenarios":"Running the kimi login/poll flow and scanning cookies before the user finishes signing in at kimi.com — the access_token cookie simply is not set yet.","commonSituations":"User is slow to complete login (2FA, email verification); login page redirected to a flow that sets cookies on a different domain timing; polling started before the browser navigated to the login URL; user abandoned the login window.","solutions":["Complete the login in the opened browser window and wait — polling continues automatically","Check for interstitial steps (2FA, captcha, email confirm) blocking cookie issuance","Confirm you are signing in on www.kimi.com so the cookie lands on the polled domain","Restart the login flow if the window was closed or the session expired mid-login"],"exampleFix":"// before\nawait startKimiLogin(); // keep polling until cookies appear\n// after\nconst session = await waitForAuthCompletion({\n  poll,\n  timeoutMs: 120000, // give the user time for 2FA etc.\n  onPollError: (e) => log('waiting for cookies: ' + e.message),\n});","handlingStrategy":"retry","validationCode":"const cookies = await page.getCookies({ url: 'https://www.kimi.com' });\nconst loggedIn = cookies.some(c => c.name === 'access_token');\nconsole.log(loggedIn ? 'session ready' : 'still waiting for user to log in');","typeGuard":"function isAuthRequiredWaiting(e) {\n  return e instanceof AuthRequiredError && /Waiting for Kimi auth cookies/.test(e.message);\n}","tryCatchPattern":"try {\n  await kimiLoginPoll(page);\n} catch (e) {\n  if (isAuthRequiredWaiting(e)) {\n    await sleep(3000); // poll again — user still logging in\n    return kimiLoginPoll(page);\n  }\n  throw e;\n}","preventionTips":["Use a generous polling timeout (2-5 min) to accommodate 2FA","Prompt the user clearly to complete sign-in in the opened window","Detect final success via hasKimiSessionCookie before stopping the poll"],"tags":["kimi","auth","login-flow","polling"],"backgroundTag":"awaiting-login-cookie","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}