diegosouzapw/OmniRoute · error · CodexDeviceFlowError

device_disabled

device_disabled

Error message

Device code login is not enabled for this account. Enable it in ChatGPT security settings (or ask your workspace admin), or use the localhost 'Adicionar' flow.

What it means

The deviceauth/usercode endpoint returned 404, meaning device-code login is disabled for the account/workspace. Actionable guidance (enable it in ChatGPT security settings or use the localhost flow) is part of the message itself.

Solutions

  1. Enable device code login in ChatGPT security settings (or ask the workspace admin)
  2. Use the localhost 'Adicionar' callback flow instead
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at src/lib/oauth/codexDeviceFlow.ts:150 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25). Data as JSON: /api/errors/6914497916d98cd8. Report an issue: GitHub.

Appendix: source

Thrown at src/lib/oauth/codexDeviceFlow.ts:150

export async function requestUserCode(
  clientId: string = DEFAULT_CLIENT_ID,
  signal?: AbortSignal
): Promise<CodexUserCode> {
  let res: Response;
  try {
    res = await fetch(`${API_BASE_URL}/deviceauth/usercode`, {
      method: "POST",
      headers: { "Content-Type": "application/json", Accept: "application/json" },
      body: JSON.stringify({ client_id: clientId }),
      signal,
    });
  } catch (e: any) {
    if (e?.name === "AbortError") throw new CodexDeviceFlowError("aborted", "Device flow aborted");
    throw new CodexDeviceFlowError("network", `Failed to reach OpenAI: ${e?.message || e}`);
  }

  if (res.status === 404) {
    throw new CodexDeviceFlowError(
      "device_disabled",
      "Device code login is not enabled for this account. Enable it in ChatGPT security settings (or ask your workspace admin), or use the localhost 'Adicionar' flow.",
      404
    );
  }

  if (!res.ok) {
    const text = await res.text().catch(() => "");
    throw new CodexDeviceFlowError(
      "usercode_failed",
      `Failed to request device code (${res.status}): ${text}`,
      res.status
    );
  }

  const data: any = await res.json();
  const userCode = data.user_code || data.usercode;
  if (!data.device_auth_id || !userCode) {

View on GitHub (pinned to a179ffed5b)