{"record":{"id":"d3fb2bc616fb9bd8","repo":"xai-org/grok-build","slug":"authorization-denied-the-user-rejected-the-reques","errorCode":null,"errorMessage":"Authorization denied. The user rejected the request.","messagePattern":"Authorization denied\\. The user rejected the request\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-shell/src/auth/device_code.rs","lineNumber":266,"sourceCode":"            let tokens: TokenOk = resp.json().await?;\n            let auth = build_auth(&tokens, issuer, client_id, auth_manager).await?;\n            return Ok((auth, true));\n        }\n\n        let err: TokenErr = resp.json().await?;\n        let detail = err.error_description.as_deref().unwrap_or(&err.error);\n        match err.error.as_str() {\n            \"authorization_pending\" => {\n                // User hasn't acted yet -- keep polling.\n                continue;\n            }\n            \"slow_down\" => {\n                poll_interval += std::time::Duration::from_secs(DEVICE_SLOW_DOWN_INCREMENT_SECS);\n                continue;\n            }\n            \"access_denied\" => {\n                tracing::warn!(description = detail, \"device auth authorization denied\");\n                anyhow::bail!(\"Authorization denied. The user rejected the request.\");\n            }\n            \"expired_token\" => {\n                tracing::warn!(description = detail, \"device auth token expired\");\n                anyhow::bail!(\"Device code expired. Run `grok login --device-auth` again.\");\n            }\n            other => {\n                tracing::warn!(\n                    error = other,\n                    description = detail,\n                    \"device auth token exchange failed\"\n                );\n                anyhow::bail!(\"Token exchange error: {detail}\");\n            }\n        }\n    }\n}\n\n/// Device-code login shared by the TUI and CLI.","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-shell/src/auth/device_code.rs#L248-L284","documentation":"The token endpoint responded with error=access_denied, meaning the user actively rejected the device-authorization request at the verification page. The client maps this OAuth2 error to a clear message that no token will be issued.","triggerScenarios":"complete_device_code_login polls the token endpoint and receives {\"error\":\"access_denied\"} after the user clicked Deny/Cancel on the verification_uri page.","commonSituations":"User misclicks Deny; a shared machine's previous session rejects on behalf of the intended user; security policy or an admin consents screen leads the user to cancel.","solutions":["Retry the login and click Allow/Authorize at the verification URL.","Re-run `grok login --device-auth` to get a fresh device code (the old one is consumed).","If rejections are unintentional, check browser session/profile — you may be signed into the wrong account.","If policy blocks consent, contact your administrator or use XAI_API_KEY instead."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match complete_device_code_login(&client, &pending).await {\n    Err(e) if e.to_string().contains(\"Authorization denied\") => {\n        eprintln!(\"You declined the request. Re-run `grok login --device-auth` and choose Allow.\");\n    }\n    other => other?,\n}","preventionTips":["Confirm the correct account is active in the browser before opening the verification URL.","Read the consent screen before clicking; use Deny only intentionally.","On shared machines, use a private/incognito window so the right account authorizes.","If rejections recur, check for security tooling or admin policy auto-denying consent."],"tags":["oauth","device-flow","user-rejected"],"backgroundTag":"oauth-access-denied","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}