{"record":{"id":"7c301813529fcc5c","repo":"BerriAI/litellm","slug":"device-code-response-missing-fields-data","errorCode":null,"errorMessage":"Device code response missing fields: {data}","messagePattern":"Device code response missing fields: (.+?)","errorType":"exception","errorClass":"GetDeviceCodeError","httpStatus":400,"severity":"error","filePath":"litellm/llms/chatgpt/authenticator.py","lineNumber":189,"sourceCode":"            )\n            resp.raise_for_status()\n            data: Final = resp.json()\n        except httpx.HTTPStatusError as exc:\n            raise GetDeviceCodeError(\n                message=f\"Failed to request device code: {exc}\",\n                status_code=exc.response.status_code,\n            )\n        except Exception as exc:\n            raise GetDeviceCodeError(\n                message=f\"Failed to request device code: {exc}\",\n                status_code=400,\n            )\n\n        device_auth_id: Final = data.get(\"device_auth_id\")\n        user_code: Final = data.get(\"user_code\") or data.get(\"usercode\")\n        interval: Final = data.get(\"interval\")\n        if not device_auth_id or not user_code:\n            raise GetDeviceCodeError(\n                message=f\"Device code response missing fields: {data}\",\n                status_code=400,\n            )\n        return {\n            \"device_auth_id\": device_auth_id,\n            \"user_code\": user_code,\n            \"interval\": str(interval or \"5\"),\n        }\n\n    def _poll_for_authorization_code(self, device_code: dict[str, str]) -> dict[str, str]:\n        client: Final = _get_httpx_client()\n        interval: Final = int(device_code.get(\"interval\", \"5\"))\n        start_time: Final = time.time()\n        while time.time() - start_time < DEVICE_CODE_TIMEOUT_SECONDS:\n            try:\n                resp = client.post(\n                    CHATGPT_DEVICE_TOKEN_URL,\n                    json={","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/chatgpt/authenticator.py#L171-L207","documentation":"GetDeviceCodeError (status 400) raised when the device-code endpoint answered HTTP 200 but the JSON body lacks device_auth_id or user_code (it does accept usercode as an alternate key). This is a response-shape mismatch: litellm parsed the JSON but could not find the fields the flow needs to display the verification code.","triggerScenarios":"A proxy or mock intercepting auth.openai.com and returning 200 with an unexpected body; OpenAI changing the device-code response schema in a way the installed litellm version does not understand.","commonSituations":"Running against a captured/replayed auth response in tests; a stale litellm version after OpenAI alters the OAuth contract; middleware (privacy proxies, captive portals) injecting a different 200 response.","solutions":["Upgrade litellm to the latest release so the parser matches the current OpenAI response schema","Disable any proxy/mock that intercepts auth.openai.com and retry against the real endpoint","Inspect the {data} payload echoed in the message to see what was actually returned","If behind corporate middleware, allowlist the auth domain so responses pass through untouched"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"from litellm.llms.chatgpt.authenticator import GetDeviceCodeError\n\ntry:\n    tokens = authenticator.login()\nexcept GetDeviceCodeError as e:\n    if \"missing fields\" in str(e):\n        # response-shape mismatch: almost always fixed by a litellm upgrade\n        print(\"Device-code response schema changed. Upgrade litellm: pip install -U litellm\")\n    raise","preventionTips":["Pin a recent litellm version and upgrade when OpenAI auth contracts change","Never mock auth.openai.com in shared environments running real logins","Allowlist auth domains in corporate proxies so responses pass through unmodified"],"tags":["chatgpt","oauth","device-code","schema-mismatch","auth"],"backgroundTag":"oauth-device-flow-failed","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}