Shipping an AI app or agent? Security review in 1 working day: $149 / ₹13,900. Request a review →
AI Review Ready
Home / Error fixes / Access token could not be refreshed
Fix · Codex CLI · Codex desktop

Codex: Your access token could not be refreshed

Fix: do what it says, sign out and in again. In the CLI: codex logout, then codex login (or codex login --device-auth if the browser callback can't reach your machine). In the app, choose Log out in the profile menu and sign in. If it keeps coming back on Windows with "already used", check that no other program holds auth.json open (#65248).

At a glance
ErrorYour access token could not be refreshed. Please log out and sign in again.
Variants...because your refresh token has expired / was already used / was revoked; ...because you have since logged out or signed in to another account
Where it comes fromCodex's request to auth.openai.com/oauth/token was refused; the server's code picks the wording
Fixcodex logout + codex login, or Log out / sign in in the app
Keeps coming back (Windows)Another process holding auth.json open can stop Codex saving new tokens (user report, #65248)
Reports3 people on GitHub, 25 Nov to 2 Dec 2026 (#63978, #64190, #65248). No OpenAI reply on these issues
Checked5 Dec 2026, against the sources listed below

What each version means

All five messages are defined in Codex's source, codex-rs/login/src/auth/manager.rs (lines 248 to 253). Codex picks one from the error code OpenAI's token server returns (lines 1876 to 1897):

Message ends withServer codeMeaning
...because your refresh token has expiredrefresh_token_expiredThe saved login is too old to renew
...because your refresh token was already usedrefresh_token_reusedThe token Codex sent had already been exchanged once
...because your refresh token was revokedrefresh_token_invalidatedThe login was revoked on OpenAI's side
...could not be refreshed. Please log out and sign in again.anything elseRefused for another reason
...because you have since logged out or signed in to another account(local check)The saved login now belongs to a different account than this session

Codex refreshes ChatGPT tokens on its own during use. OpenAI's auth docs: "Codex refreshes tokens automatically during use before they expire, so active sessions usually continue without requiring another browser login." You only see this message when that renewal is refused. Codex doesn't retry it: RefreshTokenFailed is in the never-retry list in codex-rs/protocol/src/error.rs.

Fix it

  1. See how you're signed in: codex login status.
  2. Sign out and in again:
    codex logout
    codex login
    In the desktop app or IDE extension, use Log out in the profile menu, then sign in. The CLI and the extension share the same saved login, so logging out of one logs out of both.
  3. No browser on that machine, or the callback is blocked? Use codex login --device-auth. OpenAI's docs: first enable device code login in your ChatGPT security settings (personal account) or workspace permissions (admin).
  4. Using WSL? The Linux side has its own ~/.codex/auth.json. In #63978 a user who kept getting this message in the desktop app backed up auth.json inside Ubuntu, ran codex login there, and could continue the existing WSL chat.

It keeps coming back with "already used" (Windows)

In #65248 a user traced a repeating refresh_token_reused on Windows (codex-cli 0.167.0) to another process holding auth.json open. The refresh succeeded on the server, but Codex couldn't replace the file (a sharing violation) and didn't report it. The next request sent the old, already-used token, and the login died. Close programs that keep that file open, such as editors, sync or backup tools watching %USERPROFILE%\.codex, then sign in again.

OpenAI's docs also describe keyring storage, which keeps credentials in the OS credential store instead of auth.json:

cli_auth_credentials_store = "keyring"

Can't sign back in?

In #64190, after a "was revoked" message, the sign-in asked for an email verification code that never arrived (Sign in with Apple, private relay address), in both the app and codex login --device-auth. Nothing on the machine fixes that: it needs OpenAI support, which that user contacted.

Keep auth.json private

OpenAI: "treat ~/.codex/auth.json like a password: it contains access tokens. Don't commit it, paste it into tickets, or share it in chat." Back it up to a private location only.

Running Claude Code, Codex or Cursor on real repos, or shipping an AI agent? A Quick Review ($149 / ₹13,900, 1 working day) checks one repo, config or setup for leaked keys, risky agent permissions and MCP servers. Request a Quick Review

FAQ

How do I fix 'Your access token could not be refreshed' in Codex?

Sign out and in again: codex logout, then codex login (or codex login --device-auth). In the app, Log out from the profile menu and sign in.

What does 'refresh token was already used' mean?

OpenAI's token server returned refresh_token_reused: the token Codex sent had already been exchanged. On Windows, one user traced repeats to another program holding auth.json open so Codex couldn't save the new tokens.

What does 'refresh token was revoked' mean?

The server returned refresh_token_invalidated: the login was revoked on OpenAI's side. Sign in again.

Where does Codex store the login?

In ~/.codex/auth.json (under CODEX_HOME) or in your OS credential store, depending on cli_auth_credentials_store. The CLI and IDE extension share it.

Related errors

Sources

Read 5 Dec 2026. These tools change often: if a step no longer matches, the linked page wins.

Related free tools