{"record":{"id":"e8c4a35da254ccad","repo":"jackwener/OpenCLI","slug":"waiting-for-ke-lianjia-token-cookie","errorCode":null,"errorMessage":"Waiting for Ke lianjia_token cookie","messagePattern":"Waiting for Ke lianjia_token cookie","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"info","filePath":"clis/ke/auth.js","lineNumber":44,"sourceCode":"        return { kind: 'auth', detail: 'Ke no user-name DOM anchor — anonymous or SSR failed' };\n      }\n      return { ok: true, username };\n    })()\n  `);\n  if (probe?.kind === 'auth') throw new AuthRequiredError('ke.com', probe.detail);\n  if (!probe?.ok) throw new CommandExecutionError(`Unexpected Ke probe: ${JSON.stringify(probe)}`);\n  return { username: probe.username };\n}\n\nregisterSiteAuthCommands({\n  site: 'ke',\n  domain: 'ke.com',\n  loginUrl: 'https://clogin.ke.com/login/?service=https%3A%2F%2Fwww.ke.com',\n  columns: ['username'],\n  verify: verifyKeIdentity,\n  poll: async (page) => {\n    if (!await hasKeSessionCookie(page)) {\n      throw new AuthRequiredError('ke.com', 'Waiting for Ke lianjia_token cookie');\n    }\n    return verifyKeIdentity(page);\n  },\n});\n","sourceCodeStart":26,"sourceCodeEnd":49,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/ke/auth.js#L26-L49","documentation":"This is the polling signal thrown by the ke site's poll callback while the login flow waits for the user to finish signing in. As long as no non-empty `lianjia_token` cookie exists on www.ke.com, poll throws AuthRequiredError('Waiting for Ke lianjia_token cookie') so the auth loop keeps waiting; it is an expected intermediate state, not a failure of your command.","triggerScenarios":"Running the interactive ke auth login flow and the poller checking the browser before the user has completed the clogin.ke.com login; login completed but the cookie is not yet set for url https://www.ke.com.","commonSituations":"User hasn't finished (or abandoned) the browser login; login succeeded on clogin.ke.com but the service-ticket redirect back to www.ke.com hasn't happened yet, so the token cookie isn't issued.","solutions":["Complete the login in the opened browser window (SMS/QR code)","Make sure the redirect lands back on www.ke.com so the service ticket is exchanged for the lianjia_token cookie","If finished but still polling, reload www.ke.com in the browser to force cookie issuance, or restart the auth command"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"const cookies = await page.getCookies({ url: 'https://www.ke.com' });\nconst ready = cookies.some(c => c.name === 'lianjia_token' && c.value);\nif (!ready) console.log('Login still pending — complete it in the browser window');","typeGuard":null,"tryCatchPattern":"// poll loop: treat this AuthRequiredError as 'keep waiting'\nconst deadline = Date.now() + 5 * 60_000;\nwhile (Date.now() < deadline) {\n  try { return await kePoll(page); }\n  catch (e) {\n    if (e instanceof AuthRequiredError && /Waiting for Ke lianjia_token/.test(e.message)) {\n      await new Promise(r => setTimeout(r, 2000)); continue;\n    }\n    throw e;\n  }\n}\nthrow new Error('Login not completed within 5 minutes');","preventionTips":["Complete the browser login promptly; the poller waits but not forever","Confirm the redirect lands back on www.ke.com so the cookie is set","If stuck, reload www.ke.com in the browser to finish the CAS ticket exchange","Use an adequate poll timeout for SMS/QR logins"],"tags":["auth","login-flow","polling","ke"],"backgroundTag":"auth-session-required","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}