Skip to main content
πŸŽ“ Claude Code Masterclass Learn AI-assisted development on Udemy β€” plus the companion book on Leanpub & Amazon. Start Learning
Codex device code authorization enabled in ChatGPT security settings
AI

Codex Device Code Auth: Enable It in ChatGPT Security Settings

Codex login fails until you enable device code authorization in ChatGPT Security Settings. Here is the exact fix, including managed workspace steps.

LB
Luca Berton
Β· 3 min read

codex login --device-auth is the cleanest way to authenticate the Codex CLI on a headless server: no browser on the box, no copy-pasting an API key, just a one-time code on a phone or laptop. But the first run often fails with no obvious error β€” the prompt appears, you complete it, and nothing logs in. The missing piece is almost always a single toggle in your ChatGPT account.

This is the exact fix, the managed-workspace exception, and the verification flow that confirms it worked.

Why the Login Stalls

Device code authorization is an OAuth flow. The CLI shows a link and a short code; you authorize the session from a separate device that already has a browser and a signed-in ChatGPT account. Codex itself does not require the toggle to start the flow β€” the prompt will happily print the code. What it requires is for your account to be allowed to redeem that code.

If device code authorization is disabled at the account or workspace level, the code is rejected server-side and the CLI never receives a token. You see the prompt, you enter the code, and the session silently fails.

The fix is not on the server. It is in ChatGPT’s Security Settings.

Enable Device Code Authorization

Open ChatGPT and navigate:

Profile β†’ Settings β†’ Security β†’ Device code authorization

Flip the toggle on. That is the entire account-level change.

For a managed workspace (ChatGPT Team, Enterprise, or Edu), the toggle may be greyed out or absent entirely. In that case an administrator must enable device-code login in the workspace permissions before any member can use it. Ask your workspace admin β€” individual members cannot override this at the account level.

Once the toggle is on (or the workspace permission is granted), re-run the login from the same machine.

Run the Login Again

codex login --device-auth

A successful run looks like this:

Welcome to Codex [v0.145.0]
OpenAI's command-line coding agent

Follow these steps to sign in with ChatGPT using device code authorization:

1. Open this link in your browser and sign in to your account
   https://auth.openai.com/codex/device

2. Enter this one-time code (expires in 15 minutes)
   AAAAB-BB6TU

Continue only if you started this login in Codex. If a website or another person gave you this code, cancel.

Successfully logged in

Open the link on any device where you are signed in to ChatGPT, paste the one-time code, and authorize. The code expires in 15 minutes, so do it in one sitting. The CLI prints Successfully logged in the moment the code is redeemed.

Security Notes

Device code authorization is designed for exactly this situation β€” a machine with no browser β€” so the secret (the short code) is low-value on its own. Treat it like a one-time PIN:

  • Only enter a code you initiated yourself. The CLI prints a warning for exactly this reason: if a website or another person gave you the code, cancel.
  • The code is single-use and short-lived. Once redeemed it cannot be reused, and a failed or timed-out code simply expires.
  • On managed workspaces, the admin-controlled permission is the real gate. If you cannot enable it, that is working as intended β€” it keeps workspace auth policy centralized.

Verify the Session

After Successfully logged in, the credentials are stored locally on that instance. You do not need to keep the code or re-run anything. To confirm the agent is usable, start a session or run a harmless command:

codex "list the files in the current directory"

If Codex responds, the device-code session is live. The redeemed code is no longer needed β€” it has already been consumed.

What I Learned

The trap with Codex device-code auth is that the failure is silent and the cause is far away from the terminal. The CLI does its part; the blocker is a security setting in your ChatGPT account, or a workspace permission your admin owns. Flip the toggle, re-run codex login --device-auth, enter the code on a signed-in device, and the session comes up cleanly β€” no API key juggling on a headless box.

#codex #openai #device-code-auth #authentication #chatgpt #cli
Share:
AI Integration & GPU Platforms

Need help with AI Integration & GPU Platforms?

Need help deploying AI/ML platforms? Get expert consulting on OpenShift AI, GPU orchestration, and MLOps.

Learn more about AI Integration & GPU Platforms

Want to operate this yourself, in production?

Take the free AI Platform Engineer Readiness Scorecard to see which skills transfer β€” then build a production-shaped AI platform in the 4-week Bootcamp.

Take the Scorecard β†’
Luca Berton β€” AI & Cloud Advisor, Docker Captain

Luca Berton

AI & Cloud Advisor Β· Docker Captain Β· KubeCon Speaker

15+ years in enterprise infrastructure. Author of 8 technical books, creator of Ansible Pilot (1M+ YouTube views, 648K site users). Former Red Hat engineer. Speaker at KubeCon EU 2026 and Red Hat Summit 2026.

Free 30-min AI & Cloud consultation

Book Now