{"record":{"id":"8e2956dc167b75a8","repo":"PrefectHQ/fastmcp","slug":"the-device-authorization-request-was-denied","errorCode":null,"errorMessage":"The device authorization request was denied","messagePattern":"The device authorization request was denied","errorType":"exception","errorClass":"DeviceAuthorizationDeniedError","httpStatus":null,"severity":"error","filePath":"fastmcp_slim/fastmcp/cli/deploy/authentication.py","lineNumber":66,"sourceCode":"                \"The device authorization request expired\"\n            )\n\n        await sleep(min(interval, remaining))\n        if monotonic() >= deadline:\n            raise DeviceAuthorizationExpiredError(\n                \"The device authorization request expired\"\n            )\n\n        result = await client.exchange_device_authorization(authorization.device_code)\n        if result.access_token is not None:\n            return result.access_token\n        if result.error == \"authorization_pending\":\n            continue\n        if result.error == \"slow_down\":\n            interval += 5\n            continue\n        if result.error == \"access_denied\":\n            raise DeviceAuthorizationDeniedError(\n                \"The device authorization request was denied\"\n            )\n        if result.error == \"expired_token\":\n            raise DeviceAuthorizationExpiredError(\n                \"The device authorization request expired\"\n            )\n\n        raise DeviceAuthorizationError(\"Device authorization failed\")\n\n\nasync def authorize_device(\n    client: HorizonClient,\n    *,\n    metadata: DeviceMetadata | None = None,\n    on_challenge: Callable[[DeviceAuthorization], None] | None = None,\n    open_browser: bool = False,\n    browser_opener: Callable[[str], object] = webbrowser.open,\n    sleep: Callable[[float], Awaitable[None]] | None = None,","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/PrefectHQ/fastmcp/blob/1f021142978e0861cd910c8df4e8074bc7cf3978/fastmcp_slim/fastmcp/cli/deploy/authentication.py#L48-L84","documentation":"When the authorization server's token endpoint responds with error='access_denied', poll_device_authorization raises DeviceAuthorizationDeniedError('The device authorization request was denied'), meaning the user actively rejected the device authorization at the verification page.","triggerScenarios":"The user clicks 'deny' / 'cancel' on the verification URI during the device flow.","commonSituations":"A user who does not recognize the app denies the request; a shared machine user declines; security-conscious users rejecting unexpected prompts.","solutions":["Re-run the login flow and approve the request this time","Verify you are logging in the intended Horizon account before approving","Confirm the verification URL came from a trusted `fastmcp deploy` run (avoid phishing prompts)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"from fastmcp.cli.deploy.authentication import DeviceAuthorizationDeniedError\ntry:\n    token = await poll_device_authorization(client, authorization)\nexcept DeviceAuthorizationDeniedError:\n    print(\"Authorization was denied; rerun login to try again\")\n    raise SystemExit(1)","preventionTips":["Recognize the app shown on the verification page before approving","Do not cancel the verification tab mid-login","Only start logins you initiated from your own terminal"],"tags":["oauth","device-flow","user-denied"],"backgroundTag":"device-flow-denied","analyzedSha":"1f021142978e0861cd910c8df4e8074bc7cf3978","analyzedAt":"2026-08-29T14:31:16.082Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}