{"record":{"id":"792094273d317f77","repo":"can1357/oh-my-pi","slug":"kimi-device-authorization-denied","errorCode":null,"errorMessage":"Kimi device authorization denied","messagePattern":"Kimi device authorization denied","errorType":"validation","errorClass":"AIError.OAuthError","httpStatus":null,"severity":"warning","filePath":"packages/ai/src/registry/oauth/kimi.ts","lineNumber":256,"sourceCode":"\t\t}\n\n\t\tif (error === \"slow_down\") {\n\t\t\twaitMs += 5000;\n\t\t\tconst retryAfter = typeof payload.interval === \"number\" ? payload.interval * 1000 : undefined;\n\t\t\tif (retryAfter && retryAfter > waitMs) waitMs = retryAfter;\n\t\t\tawait scheduler.wait(waitMs, { signal });\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (error === \"expired_token\") {\n\t\t\tthrow new AIError.OAuthError(\"Kimi device authorization expired\", {\n\t\t\t\tkind: \"validation\",\n\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","sourceCodeStart":238,"sourceCodeEnd":274,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/ai/src/registry/oauth/kimi.ts#L238-L274","documentation":"Thrown during the Kimi OAuth device-authorization polling loop when Kimi's token endpoint returns error='access_denied', meaning the user explicitly denied the authorization request in the browser (or the consent page was closed/dismissed in a way Kimi treats as denial). The library maps it to AIError.OAuthError with kind='validation' since no retry can succeed. It is terminal for this login attempt; a fresh device code must be requested.","triggerScenarios":"loginKimi() starts the device flow and the user clicks 'Deny'/'Cancel' on Kimi's consent page instead of approving; the code is also reached if the consent page reports access_denied after the code expired or was already used.","commonSituations":"User gets cold feet or doesn't recognize the login request; shared machine where another person denies the prompt; corporate/security software auto-dismissing OAuth consent pages; user taking too long so the code expires and the page shows a denial-like error.","solutions":["Re-run loginKimi() and approve the authorization prompt in the browser this time","Verify you are completing the consent in the same browser session within the code's expiry window","If denials are unexpected, check for security extensions/policies blocking OAuth consent pages","If automating, do not auto-dismiss the consent URL printed by the CLI"],"exampleFix":"// before: user denies, login crashes mid-script\nawait loginKimi();\n// after: handle denial and prompt again\ntry {\n  await loginKimi();\n} catch (e) {\n  if (e instanceof AIError.OAuthError && e.message.includes('denied')) {\n    console.error('Authorization was denied. Please retry and click Approve.');\n    await loginKimi();\n  } else throw e;\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await loginKimi();\n} catch (e) {\n  if (e instanceof AIError.OAuthError && e.message === 'Kimi device authorization denied') {\n    // prompt the user to retry and approve\n  } else throw e;\n}","preventionTips":["Instruct users before starting that they must click Approve in the browser","Show the verification URL and code prominently and keep the process in the foreground","Never auto-dismiss or script the consent page"],"tags":["oauth","kimi","device-flow","user-denied"],"backgroundTag":"oauth-access-denied","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}