{"record":{"id":"0abe729094c85754","repo":"jdx/mise","slug":"github-device-authorization-was-denied","errorCode":null,"errorMessage":"GitHub device authorization was denied","messagePattern":"GitHub device authorization was denied","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/github/oauth.rs","lineNumber":366,"sourceCode":"                    debug!(\"transient error polling GitHub OAuth token: {err:#}\");\n                    continue;\n                }\n            },\n            Err(err) => {\n                debug!(\"transient error polling GitHub OAuth token: {err:#}\");\n                continue;\n            }\n        };\n\n        match response.error.as_deref() {\n            None => return Ok(response),\n            Some(\"authorization_pending\") => continue,\n            Some(\"slow_down\") => {\n                interval += 5;\n                continue;\n            }\n            Some(\"expired_token\") => bail!(\"GitHub device authorization expired\"),\n            Some(\"access_denied\") => bail!(\"GitHub device authorization was denied\"),\n            Some(error) => {\n                let details = response\n                    .error_description\n                    .unwrap_or_else(|| error.to_string());\n                bail!(\"{details}\");\n            }\n        }\n    }\n}\n\nasync fn refresh_token(cached: &CachedToken) -> Result<Option<CachedToken>> {\n    let Some(refresh_token) = cached.refresh_token.as_deref() else {\n        return Ok(None);\n    };\n    if cached\n        .refresh_expires_at\n        .is_some_and(|exp| exp <= chrono::Utc::now())\n    {","sourceCodeStart":348,"sourceCodeEnd":384,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/github/oauth.rs#L348-L384","documentation":"In the GitHub OAuth device flow, poll_access_token polls the token endpoint until the user approves or denies the request at github.com/login/device. When GitHub returns error='access_denied', the user (or an org policy) explicitly denied the OAuth application's authorization request, and the code bails with this error. It is a deliberate rejection, not a transient failure.","triggerScenarios":"token_async -> poll_access_token receives 'access_denied' from GitHub because the user clicked 'Cancel'/'Deny' on the device authorization page, or an organization OAuth app policy blocks the authorization.","commonSituations":"User misclicks cancel on the device page; corporate SSO/org restrictions deny third-party OAuth apps; user re-runs the flow and denies the old pending request.","solutions":["Re-run the command and click 'Authorize' on the github.com/login/device page","Check GitHub Organization settings -> Third-party application access policy and request approval for the app","If SSO is required, authorize the app for the org via SSO settings before retrying","Use a personal access token (GITHUB_TOKEN) instead of OAuth device flow"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match err {\n    OAuthError::AccessDenied => {\n        eprintln!(\"Authorization was denied. Re-run and click 'Authorize' at https://github.com/login/device\");\n    }\n    e => return Err(e),\n}","preventionTips":["Tell the user explicitly to click Authorize, not Cancel, on the device page","Check org third-party OAuth app policies before rolling out the flow","Provide a PAT/GITHUB_TOKEN fallback path","Handle denial gracefully with a re-run prompt"],"tags":["oauth","github","authentication","access-denied"],"backgroundTag":"oauth-token-exchange-failed","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}