openclaw - 💡(How to fix) Fix Control UI device token mismatch loop after scope upgrade causes rate-limit lockout [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#71609Fetched 2026-04-26 05:10:42
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

Error Message

  1. Misleading error messaging: The error "rotate/reissue device token" implies the user should obtain a new token, when in fact the problem is stale credentials that should be discarded, not rotated.
  2. Error messages during mismatch should direct users toward reconnecting / clearing state, not "rotate/reissue"

Root Cause

Three compounding issues:

  1. No stale token cleanup on mismatch: When device_token_mismatch is detected, the frontend does not invalidate/clear the old browser device credentials. It retries with a newly generated identity instead.

  2. Stale local credentials preferred over URL token: The frontend appears to prioritize its own stored device token over the fresh token embedded in the dashboard URL, perpetuating the mismatch.

  3. Misleading error messaging: The error "rotate/reissue device token" implies the user should obtain a new token, when in fact the problem is stale credentials that should be discarded, not rotated.

RAW_BUFFERClick to expand / collapse

Bug Description

After a device scope upgrade / device approval, the Control UI enters an authentication failure loop:

  1. Browser holds stale local device credentials
  2. Gateway switches to new device token/permission state after approval
  3. Browser reconnects with mismatched token → device_token_mismatch
  4. Frontend does not clear old device state; instead it generates a new instanceId and retries
  5. Each retry produces another mismatch → another new instanceId
  6. Rapid accumulation of failed attempts triggers rate_limited: too many failed authentication attempts (retry later)
  7. User is locked out of Control UI; only fix is temporarily setting gateway.auth.mode=none

Steps to Reproduce

  1. Use OpenClaw with Control UI (webchat) normally
  2. Perform a scope upgrade / device approval via the gateway
  3. Attempt to continue using the Control UI in the same browser session
  4. Observe: redirected to login page showing WebSocket URL + gateway token
  5. Observe in gateway logs: repeated device_token_mismatch with incrementing instanceId values
  6. Eventually hits rate limit and is fully locked out

Gateway Log Evidence

Multiple distinct instanceId values appear in rapid succession:

  • 14753151-3dac-4f0e-98a3-2be1b3327abb
  • 17f4c557-1cd9-40e6-b3d7-54783f219f20
  • 52abe396-df05-4daf-84e5-7f84f2f7d2bf
  • c69afb9e-0981-4c17-9405-27d6a2d066ca

Each with authReason: device_token_mismatch, followed by authReason: rate_limited.

Root Cause Analysis

Three compounding issues:

  1. No stale token cleanup on mismatch: When device_token_mismatch is detected, the frontend does not invalidate/clear the old browser device credentials. It retries with a newly generated identity instead.

  2. Stale local credentials preferred over URL token: The frontend appears to prioritize its own stored device token over the fresh token embedded in the dashboard URL, perpetuating the mismatch.

  3. Misleading error messaging: The error "rotate/reissue device token" implies the user should obtain a new token, when in fact the problem is stale credentials that should be discarded, not rotated.

Expected Behavior

After a scope upgrade / device approval:

  • Gateway should detect token drift and signal the frontend to clear old device state
  • Frontend should automatically re-authenticate with fresh credentials
  • Or: the Control UI should clearly indicate "device identity expired, reconnecting…" rather than showing a login shell

Suggested Fixes

  1. On device_token_mismatch, the gateway should send a signal instructing the frontend to clear stored device identity before retrying
  2. When generating a fresh dashboard URL with embedded token, the frontend should prioritize that over any stored device token
  3. Error messages during mismatch should direct users toward reconnecting / clearing state, not "rotate/reissue"
  4. Consider a more graceful recovery path: when a mismatch is detected post-approval, auto-invalidate the old device token server-side rather than waiting for client retry loop

Environment

  • OpenClaw version: 2026.4.23
  • Platform: macOS (Darwin 26.3, arm64)
  • Node: v22.22.2
  • Gateway: local mode, loopback bind
  • Auth mode: token
  • Control UI: webchat via Chrome on MacIntel

extent analysis

TL;DR

Clearing stale device credentials and prioritizing fresh tokens can resolve the authentication failure loop.

Guidance

  • On detecting device_token_mismatch, the frontend should clear stored device identity before retrying to prevent the accumulation of failed attempts.
  • The frontend should prioritize the fresh token embedded in the dashboard URL over any stored device token to ensure seamless re-authentication.
  • Error messages should be updated to direct users toward reconnecting or clearing state instead of suggesting token rotation.
  • Consider implementing a server-side mechanism to auto-invalidate old device tokens after approval to prevent client-side retry loops.

Example

No code snippet is provided as the issue description does not include specific code references.

Notes

The suggested fixes aim to address the compounding issues of stale token cleanup, token prioritization, and misleading error messaging. However, the effectiveness of these fixes may depend on the specific implementation details of the OpenClaw and gateway systems.

Recommendation

Apply the suggested fixes, particularly focusing on clearing stale device credentials and prioritizing fresh tokens, as these address the root causes of the authentication failure loop.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Control UI device token mismatch loop after scope upgrade causes rate-limit lockout [1 participants]