claude-code - 💡(How to fix) Fix Feature request: claude setup-token --list and --revoke <id> subcommands [1 comments, 2 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
anthropics/claude-code#48373Fetched 2026-04-16 07:02:00
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Author
Timeline (top)
labeled ×4commented ×1

Add two subcommands to claude setup-token:

  1. claude setup-token --list — enumerate all currently-valid long-lived OAuth tokens issued for the authenticated account
  2. claude setup-token --revoke <token-id> — revoke a specific token by its id (as shown in --list)

Error Message

  • Return non-zero with a distinguishable error code if the token doesn't exist, is already revoked, or the caller isn't authorized

Root Cause

  • claude setup-token --list exists, returns JSON on --json, and shows at least the token id, creation time, and optional label
  • claude setup-token --revoke <token-id> exists and revokes the named token
  • Running a previously-valid token after revocation returns 401 from the API
  • The Consumer Terms §3 "no automated access" clause is satisfied because these subcommands are first-party and explicitly permitted by Anthropic shipping them
RAW_BUFFERClick to expand / collapse

Summary

Add two subcommands to claude setup-token:

  1. claude setup-token --list — enumerate all currently-valid long-lived OAuth tokens issued for the authenticated account
  2. claude setup-token --revoke <token-id> — revoke a specific token by its id (as shown in --list)

Motivation

I'm building an incident-response runbook for a containerized Claude Code deployment (homototus/ecc-sandbox). The runbook handles the case where a sandboxed Claude Code container is compromised and we need to revoke the per-experiment OAuth token fast, ideally within 5 minutes of detection.

Today, claude setup-token --help shows no options — the command is mint-only. There's no way to list or revoke a previously-minted token from the CLI. The only path is the web console at https://console.anthropic.com/settings/keys, which:

  • Requires a human to open a browser and click buttons
  • Can't be scripted into an incident-response flow
  • Assumes the operator has console reach (network, working cookies, no account-level compromise)

Without scriptable revocation, the incident-response flow has to fall back to droplet-side containment (kill local processes, block egress at iptables, quarantine the systemd-creds credential file) and wait for the human operator to complete the Anthropic-side revocation manually. That leaves a gap between "compromise detected" and "token invalidated at Anthropic" where the token is still live.

Proposed behavior

claude setup-token --list

Output a stable format (JSON on --json, human-readable otherwise) listing each token with:

  • Token id (short hash, safe to print in logs)
  • Creation timestamp
  • Label (if set at mint time via a proposed --label <name> option)
  • Last-used timestamp (if the backend tracks it)
  • Source device/session fingerprint (if available)

claude setup-token --revoke <token-id>

  • Revoke the specified token immediately
  • Return non-zero with a distinguishable error code if the token doesn't exist, is already revoked, or the caller isn't authorized
  • The currently-authenticated session can revoke its own token (forces re-auth on next command) or any token on the account

Use cases

  1. Incident response — scripted teardown can include a real revocation step instead of a manual reminder
  2. Token rotation — weekly rotation rituals can revoke the old token atomically after minting the new one
  3. Audit--list lets operators periodically check whether any unexpected tokens exist on the account
  4. CI/CD cleanup — ephemeral CI runners can revoke their token on teardown instead of leaking long-lived credentials

Acceptance criteria

  • claude setup-token --list exists, returns JSON on --json, and shows at least the token id, creation time, and optional label
  • claude setup-token --revoke <token-id> exists and revokes the named token
  • Running a previously-valid token after revocation returns 401 from the API
  • The Consumer Terms §3 "no automated access" clause is satisfied because these subcommands are first-party and explicitly permitted by Anthropic shipping them

Context

I'm happy to contribute a PR if the design is accepted. The incident-response use case is documented in ecc-sandbox PLAN.md §Panic button (private repo — I can paste the relevant section here if helpful).

Thanks for considering.

extent analysis

TL;DR

To address the issue, implement the proposed claude setup-token --list and claude setup-token --revoke <token-id> subcommands to enable scriptable token revocation and listing.

Guidance

  • Implement the --list subcommand to return a list of currently valid long-lived OAuth tokens in a stable format (JSON or human-readable).
  • Implement the --revoke <token-id> subcommand to immediately revoke a specified token and return an error code if the token doesn't exist, is already revoked, or the caller isn't authorized.
  • Ensure the --revoke subcommand allows the currently authenticated session to revoke its own token or any token on the account.
  • Test the implementation to satisfy the acceptance criteria, including token listing, revocation, and error handling.

Example

No code snippet is provided as the issue does not include specific implementation details.

Notes

The implementation should consider the Consumer Terms §3 "no automated access" clause and ensure that the subcommands are first-party and explicitly permitted by Anthropic.

Recommendation

Apply the proposed subcommands to enable scriptable token revocation and listing, as this will address the incident-response use case and provide a more secure and efficient way to manage OAuth tokens.

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

claude-code - 💡(How to fix) Fix Feature request: claude setup-token --list and --revoke <id> subcommands [1 comments, 2 participants]