# Atlas: xAI device code expired, denied, or timed out

> Re-run `atlas auth login` for xai and approve in the browser promptly. Check the machine clock too, since skew shortens the effective device-code lifetime.

Atlas ends an xAI login with "xAI device code expired - please re-run login", "xAI device authorization was denied", or "xAI device authorization timed out" because the xAI plugin polls the device token endpoint and reports each outcome separately. The fix is to re-run atlas auth login for xai and complete the browser approval promptly. If you accidentally clicked deny, start a fresh device flow, and confirm the machine's clock is correct, because skew shortens the effective device-code lifetime.

## Symptom

The xAI login ends with one of: xAI device code expired - please re-run login; xAI device authorization was denied; xAI device authorization timed out.

## Cause

The xAI plugin in Atlas polls the device token endpoint. It distinguishes an expired device code, an explicit denial, and exhausting the polling window, and throws a different message for each, so the message you get names which of the three actually happened.

## Fix

1. Re-run `atlas auth login` for xai and complete the browser approval promptly, before the device code expires.
2. If you accidentally clicked deny, start a fresh device flow. A denied authorization cannot be reversed in place.
3. Confirm the machine's clock is correct. Clock skew shortens the effective device-code lifetime and makes codes expire early.
4. If the device code request itself fails, the message is: xAI device code request failed (<status>). That points at network or credentials rather than at anything you did in the browser.

## Why does Atlas say xAI device code expired

Atlas says "xAI device code expired - please re-run login" because the xAI plugin polls the device token endpoint and the device code aged out before you approved it in the browser. The plugin reports expiry, denial, and timeout as 3 distinct messages, so expiry means the code itself lapsed.

Device codes are short-lived by design. The xAI plugin in Atlas issues one, then polls the device token endpoint waiting for you to approve in the browser. If the approval does not land in time, the code expires and Atlas tells you exactly that, with the instruction to re-run login. There is no way to revive an expired device code. Starting a fresh flow and approving without delay is the entire fix, and the phrasing of the message is deliberate: Atlas is naming the specific one of three possible outcomes rather than giving you a generic login failure.

## xAI device authorization was denied: what to do

Atlas throws "xAI device authorization was denied" when the browser approval was explicitly rejected rather than left to expire. Denial is 1 of the 3 outcomes the xAI plugin distinguishes, and it is final, so if you clicked deny by accident you must start a fresh device flow.

Denial is distinct from expiry and from timeout, and the xAI plugin distinguishes all three deliberately. A denied authorization is a decision that has been recorded, so there is nothing left to wait for. Re-run `atlas auth login` for xai to issue a new device code, open the approval page again, and approve rather than deny. If the denial was not accidental, then the xAI account or the approval page is telling you something about access permissions, and re-running the flow will simply reproduce the denial.

## xAI device authorization timed out: what it means

Atlas throws "xAI device authorization timed out" when the xAI plugin exhausted its polling window without a decision arriving from the device token endpoint. A timeout is the 3rd outcome the plugin models: no approval and no denial ever landed, which usually means the browser approval page was never completed.

The timeout is the third distinct outcome the xAI plugin models. Where expiry says the code lapsed and denial says the request was rejected, a timeout says Atlas stopped waiting. In practice they resolve the same way: re-run `atlas auth login` for xai and finish the browser approval promptly rather than leaving the tab open. If timeouts happen repeatedly even when you approve quickly, look at whether the polling requests to the device token endpoint are reaching xAI at all, since a blocked egress path produces a silent wait that ends in exactly this message.

## Why the machine clock affects xAI device code expiry

Confirm the machine's clock is correct when xAI device codes expire in Atlas, because clock skew shortens the effective device-code lifetime. That check is step 3 of the 4 documented fix steps: a machine running ahead of real time treats a freshly issued device code as older than it is.

Clock skew is the cause people rarely check and it produces the most confusing version of this failure: you approve quickly, well inside what should be the window, and Atlas still reports "xAI device code expired - please re-run login". Fix the system time, ideally with network time synchronization, then re-run `atlas auth login` for xai. On a corporate or virtual machine that has been suspended and resumed, drifting clocks are common enough to be worth ruling out before anything else.

## xAI device code request failed: a different error

Atlas throws "xAI device code request failed (<status>)" when the device code request itself fails, which is a different error from the 3 browser-side outcomes of expiry, denial, and timeout. That message points at network or credentials, because the flow never got as far as a browser approval.

Read the message you actually received before you start fixing. Expiry, denial, and timeout all describe what happened after a device code was issued and you were sent to the browser. "xAI device code request failed (<status>)" means no device code was ever issued, so re-approving faster will change nothing. The HTTP status in the parentheses is the lead: it tells you whether xAI rejected the request or whether it never arrived. Check egress to xAI and check the credentials the request was made with.

## How to verify the xAI login fix worked

Verify the xAI login fix in Atlas by re-running `atlas auth login` for xai, approving in the browser, and confirming the flow completes with none of the 3 failure messages. Then select an xAI model and send a message to confirm the stored credentials actually work.

Completing the auth flow is necessary but not sufficient. Select an xAI model in Atlas afterwards and send a real message, because a login that reports success and a provider that answers are two separate facts. Atlas lets you switch the active model and provider on the fly with favorites and recents, so the check takes seconds. If a device code expires again on a repeat attempt despite a prompt approval, the clock is the next thing to verify rather than the flow itself.

## FAQ

### How do I fix xAI device code expired in Atlas

Re-run `atlas auth login` for xai and complete the browser approval promptly. An expired device code cannot be revived, so a fresh device flow is required.

### What is the difference between xAI device code expired and timed out

Expired means the device code itself lapsed. "xAI device authorization timed out" means the xAI plugin exhausted its polling window with no approval or denial arriving. Atlas throws a different message for each.

### I clicked deny on the xAI approval page by mistake

Start a fresh device flow with `atlas auth login` for xai. Atlas throws "xAI device authorization was denied" and treats the denial as final, so it cannot be reversed in place.

### Why do my xAI device codes expire immediately

Check the machine's clock. Clock skew shortens the effective device-code lifetime, so a machine whose time is wrong will treat a fresh xAI device code as already old.

### What does xAI device code request failed mean

"xAI device code request failed (<status>)" means no device code was issued at all. That points at network or credentials rather than at the browser approval, and the HTTP status names the rejection.

### How does Atlas know whether xAI login expired, was denied, or timed out

The xAI plugin polls the device token endpoint and distinguishes an expired device code, an explicit denial, and exhausting the polling window, throwing a different message for each case.

---

Canonical HTML: https://runatlas.sh/resources/troubleshooting/xai-device-code-expired
Source of truth: aeo_pages row `/resources/troubleshooting/xai-device-code-expired` (segment: Troubleshooting) (this file is generated from it, never hand-edited).
Licence: Atlas is proprietary with a free core. It is not open source and there is no public source repository.
