BerriAI/litellm · error · GetDeviceCodeError

Device code response missing fields: {data}

Error message

Device code response missing fields: {data}

What it means

Raised as `GetDeviceCodeError` (status 400) when the device-code endpoint returns HTTP 200 but the JSON body lacks `device_auth_id` or `user_code` (the code also accepts `usercode` as an alias). This means OpenAI's auth API changed shape or returned an unexpected payload.

Source

Thrown at litellm/llms/chatgpt/authenticator.py:189

            )
            resp.raise_for_status()
            data: Final = resp.json()
        except httpx.HTTPStatusError as exc:
            raise GetDeviceCodeError(
                message=f"Failed to request device code: {exc}",
                status_code=exc.response.status_code,
            )
        except Exception as exc:
            raise GetDeviceCodeError(
                message=f"Failed to request device code: {exc}",
                status_code=400,
            )

        device_auth_id: Final = data.get("device_auth_id")
        user_code: Final = data.get("user_code") or data.get("usercode")
        interval: Final = data.get("interval")
        if not device_auth_id or not user_code:
            raise GetDeviceCodeError(
                message=f"Device code response missing fields: {data}",
                status_code=400,
            )
        return {
            "device_auth_id": device_auth_id,
            "user_code": user_code,
            "interval": str(interval or "5"),
        }

    def _poll_for_authorization_code(self, device_code: dict[str, str]) -> dict[str, str]:
        client: Final = _get_httpx_client()
        interval: Final = int(device_code.get("interval", "5"))
        start_time: Final = time.time()
        while time.time() - start_time < DEVICE_CODE_TIMEOUT_SECONDS:
            try:
                resp = client.post(
                    CHATGPT_DEVICE_TOKEN_URL,
                    json={

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Upgrade litellm to the latest release — the parsing code is updated when OpenAI changes the contract.
  2. Inspect the raw response by enabling debug logging or curling the device-code URL manually to see what body comes back.
  3. If a proxy is returning a block page, bypass it or allowlist OpenAI auth domains.
  4. Report the issue to the litellm repo with the (redacted) response body if the API changed.
Defensive patterns

Strategy: try-catch

Try / catch

try:
    device = authenticator._request_device_code()
except GetDeviceCodeError as e:
    if "missing fields" in str(e):
        # API contract drift or proxy block page: inspect body, upgrade litellm
        log.error("unexpected device-code payload: %s", e.message)
    raise

Prevention

When it happens

Trigger: Calling `get_access_token()` on the ChatGPT authenticator when the device-code response omits required fields — typically after an API contract change on OpenAI's side, or when a proxy/interceptor returns 200 with an HTML or differently-shaped JSON body.

Common situations: litellm version out of date relative to OpenAI's auth API changes; transparent proxies that respond 200 with a block page; rare server-side bugs returning incomplete payloads.

Related errors


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/7c301813529fcc5c. Report an issue: GitHub.