{"record":{"id":"eeeedb7e14162610","repo":"can1357/oh-my-pi","slug":"kimi-device-flow-timed-out","errorCode":null,"errorMessage":"Kimi device flow timed out","messagePattern":"Kimi device flow timed out","errorType":"exception","errorClass":"AIError.OAuthError","httpStatus":null,"severity":"warning","filePath":"packages/ai/src/registry/oauth/kimi.ts","lineNumber":269,"sourceCode":"\t\t\t\tprovider: \"kimi\",\n\t\t\t});\n\t\t}\n\n\t\tif (error === \"access_denied\") {\n\t\t\tthrow new AIError.OAuthError(\"Kimi device authorization denied\", {\n\t\t\t\tkind: \"validation\",\n\t\t\t\tprovider: \"kimi\",\n\t\t\t});\n\t\t}\n\n\t\tconst description = payload.error_description ? `: ${payload.error_description}` : \"\";\n\t\tthrow new AIError.OAuthError(`Kimi device flow failed: ${error ?? response.status}${description}`, {\n\t\t\tkind: \"polling\",\n\t\t\tprovider: \"kimi\",\n\t\t});\n\t}\n\n\tthrow new AIError.OAuthError(\"Kimi device flow timed out\", {\n\t\tkind: \"timeout\",\n\t\tprovider: \"kimi\",\n\t});\n}\n\n/**\n * Login with Kimi Code OAuth (device code flow).\n */\nexport async function loginKimi(options: OAuthController): Promise<OAuthCredentials> {\n\tconst device = await requestDeviceAuthorization();\n\toptions.onAuth?.({\n\t\turl: device.verificationUriComplete,\n\t\tinstructions: `Enter code: ${device.userCode}`,\n\t});\n\n\treturn pollForToken(device.deviceCode, device.intervalMs, device.expiresInMs, options.signal);\n}\n","sourceCodeStart":251,"sourceCodeEnd":287,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/ai/src/registry/oauth/kimi.ts#L251-L287","documentation":"Thrown when the Kimi device-authorization polling loop exhausts its maximum number of polls (or overall time budget) without the user completing authorization. The library classifies it as kind='timeout' because the flow simply never concluded — Kimi kept returning authorization_pending until the loop gave up. A new device code is required; the old one is expired.","triggerScenarios":"loginKimi() prints the verification URL and user_code, but the user never opens the page or never clicks approve before the poll loop reaches its max iterations/interval budget.","commonSituations":"User walks away and forgets to authorize; headless/SSH session where the URL isn't visible; user pastes the code into the wrong account or browser; Kimi's session expiry being shorter than the CLI's poll budget.","solutions":["Re-run loginKimi() and complete the browser authorization promptly","Open the printed verification URL immediately and confirm the user_code matches","Ensure you are approving in a browser where you are (or can) log in to the correct Kimi account","If repeatedly timing out on a remote box, copy the URL to your local machine's browser"],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await loginKimi();\n} catch (e) {\n  if (e instanceof AIError.OAuthError && e.kind === 'timeout') {\n    console.error('Timed out waiting for Kimi authorization — run login again and approve promptly.');\n  } else throw e;\n}","preventionTips":["Open the verification URL immediately when printed","Complete the flow in a browser already logged into the right Kimi account","On headless machines, relay the URL to a browser you control before the poll budget expires"],"tags":["oauth","kimi","device-flow","timeout"],"backgroundTag":"oauth-device-flow-timeout","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}