{"record":{"id":"ef42936effce795b","repo":"BerriAI/litellm","slug":"timed-out-waiting-for-device-authorization","errorCode":null,"errorMessage":"Timed out waiting for device authorization","messagePattern":"Timed out waiting for device authorization","errorType":"exception","errorClass":"GetAccessTokenError","httpStatus":408,"severity":"error","filePath":"litellm/llms/chatgpt/authenticator.py","lineNumber":243,"sourceCode":"                    continue\n                resp.raise_for_status()\n            except httpx.HTTPStatusError as exc:\n                status_code = exc.response.status_code if exc.response else None\n                if status_code in (403, 404):\n                    time.sleep(max(interval, DEVICE_CODE_POLL_SLEEP_SECONDS))\n                    continue\n                raise GetAccessTokenError(\n                    message=f\"Polling failed: {exc}\",\n                    status_code=exc.response.status_code,\n                )\n            except Exception as exc:\n                raise GetAccessTokenError(\n                    message=f\"Polling failed: {exc}\",\n                    status_code=400,\n                )\n            time.sleep(max(interval, DEVICE_CODE_POLL_SLEEP_SECONDS))\n\n        raise GetAccessTokenError(\n            message=\"Timed out waiting for device authorization\",\n            status_code=408,\n        )\n\n    def _exchange_code_for_tokens(self, code_data: dict[str, str]) -> dict[str, str]:\n        try:\n            client: Final = _get_httpx_client()\n            redirect_uri: Final = f\"{CHATGPT_AUTH_BASE}/deviceauth/callback\"\n            body: Final = (\n                \"grant_type=authorization_code\"\n                f\"&code={code_data['authorization_code']}\"\n                f\"&redirect_uri={redirect_uri}\"\n                f\"&client_id={CHATGPT_CLIENT_ID}\"\n                f\"&code_verifier={code_data['code_verifier']}\"\n            )\n            resp: Final = client.post(\n                CHATGPT_OAUTH_TOKEN_URL,\n                headers={\"Content-Type\": \"application/x-www-form-urlencoded\"},","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/chatgpt/authenticator.py#L225-L261","documentation":"GetAccessTokenError with status 408 raised after the ChatGPT device-authorization poll loop exhausts its time budget without the user approving the code. The flow printed a verification URL and code, polled until the deadline, and gave up — 'Timed out waiting for device authorization'. It is a user-inaction timeout, not a network failure.","triggerScenarios":"User never visited CHATGPT_DEVICE_VERIFY_URL and entered the user_code before the poll deadline; the code was entered too late or the browser session was on a different account that never approved.","commonSituations":"Headless/CI runs where nobody sees the printed code; user stepping away from the terminal; codes expiring (they are short-lived by OAuth design); output swallowed by logging so the user never saw the prompt.","solutions":["Restart the login and complete the verification immediately after the code is printed","Make sure the user_code and verify URL are surfaced to the human (do not swallow stdout in logs)","Approve with the same OpenAI/ChatGPT account the flow expects","If it recurs in automation, pre-provision an API key or auth file instead of interactive device login"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"from litellm.llms.chatgpt.authenticator import GetAccessTokenError\n\ntry:\n    tokens = authenticator.login()\nexcept GetAccessTokenError as e:\n    if e.status_code == 408:  # user never approved in time\n        print(\"Login timed out. Restart and approve the code promptly.\")\n        tokens = authenticator.login()\n    else:\n        raise","preventionTips":["Surface the printed device code to a human immediately (do not bury stdout in logs)","For headless automation, pre-provision the auth file or an API key instead of device login","Complete verification in the same session as the login attempt"],"tags":["chatgpt","oauth","device-code","timeout","auth"],"backgroundTag":"oauth-device-flow-timeout","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}