The refresh token rotates on every use
A successful refresh returns a new refresh token and retires the one you sent. Anything still holding the old value is holding something that can never be used again.
Codex CLI fix: Codex keeps asking you to sign in again
The refresh token rotates every time it is used, and presenting one that has already been spent revokes the login outright. That makes a second copy of auth.json a way to lose the first one.
refresh token was revoked. Please log out and sign in again.
Printed by Codex CLI.
Diagnosis
A successful refresh returns a new refresh token and retires the one you sent. Anything still holding the old value is holding something that can never be used again.
Presenting an already-spent refresh token does not fail quietly, it revokes the login. Measured the hard way while building account switching: refreshing twice and then replaying the original killed the session outright.
Two processes against one auth.json is the usual shape. A credential file copied to another machine, a restored backup, or a second long-lived helper refreshing beside the CLI. None of them is doing anything wrong on its own.
Check
| Run this | What a good answer looks like |
|---|---|
codex login status | Whether this machine still believes it is signed in. A revoked login often looks fine locally until the next refresh is attempted. |
ls -l ~/.codex/auth.json | The modification time is when the credential last rotated. Two machines whose copies both keep changing is the shared-file case, visible without reading either file. |
Every command here has been run on a real machine. Termdeck answers the same questions for every machine you have connected, without opening a terminal on any of them.
Fix
The revocation is final for that token. A fresh sign-in mints a new pair, which is exactly what the message asks for.
Otherwise the new token is spent by whichever process reaches it first and the loop resumes within the hour. Sign in on one machine and let the other sign in for itself.
Two machines can use the same account. What they cannot share is one credential file.
Not this
This is the thing that causes it. Two machines sharing one credential file will keep revoking each other, and each revocation looks like a fresh problem.
A restored file is by definition an old token, so restoring one is the same as replaying it, with the same result.
FAQ
Something else is refreshing the same credential: a second process, a sync tool copying the file, or a restored backup. All three look identical from the server side.
It fixes it until the same second reader spends the new token. Remove the cause first, then sign in.
No. Reuse detection is deliberate, and it is what stops a leaked token being used behind you.
Claude Code, Codex and Grok in one browser console