Repository navigation
feat(cli): Add token commands for org auth tokens - #1647
Merged
Merged
Conversation
Add `sentry token list`, `sentry token create`, and `sentry token delete` for managing org auth tokens (the org:ci tokens used for source map, debug file, and release uploads). `sentry tokens` aliases `token list`. Sentry only lets OAuth application tokens holding `org:tokens` manage org auth tokens (getsentry/sentry#128051). `org:tokens` stays out of the default login scopes so `sentry auth login` keeps working against older self-hosted servers that don't know it. Instead, `ensureScopesForAction` now requests scopes outside the defaults on demand: the device flow asks for the defaults, the known opt-in scopes the grant already holds, and the scopes the action needs. Creating a token also needs `org:ci` (an OAuth caller can only mint scopes it holds), and revoking one needs `org:write`. Co-Authored-By: BYK <burak.kaya@sentry.io>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
--dry-run disables interactive prompts, so a dry run of token delete on a login without org:tokens can't elevate and the token lookup fails with 403. Say that --dry-run is one of the flags that skips re-authorization.
Member
|
just seeing this now, i'll get to it today! |
Member
|
found two things while reviewing and fixed them in ac0edfd:
added regression coverage for both; all 77 targeted tests pass. |
BYK
requested changes
Nov 4, 2026
token delete revokes by the numeric ID from 'sentry token list'. Make the argument help and examples say so, and reject sntrys_/sntryu_ values without echoing the secret back into the terminal or errors.
Stricli's 'Failed to parse "<input>"' message quotes the raw argument, so a pasted sntrys_/sntryu_ token still reached the terminal even after token delete refused it. Redact the formatted message like other CLI error output.
BYK
requested changes
Nov 4, 2026
BYK
left a comment
Member
There was a problem hiding this comment.
You should realize that this PR has merge conflicts?
Resolve conflicts with main's command manifest (#1918), build-only output schemas (#1923) and toolkit-core Markdown builders (#1805): - Register token/tokens in app.ts, command-manifest.ts, app-root.ts plurals and top-level-briefs.ts - Re-export OrgAuthTokenSchema from output-schemas/token.ts (it also validates API responses) and read token list's fields from generated data - Use text/inlineCode/tableCell from @sentry/toolkit-core/markdown - Move the argument-error credential redaction to lib/application.ts
In a TTY the rendered code span wraps the token in color codes and a space on each side, so copying the line could pick up an invalid credential, and Sentry can't show the token again. Print the value as a plain line after the rendered summary.
BYK
requested changes
Nov 4, 2026
BYK
left a comment
Member
There was a problem hiding this comment.
We should also accept the token name for token delete etc.
A token can now be revoked by the name shown in 'sentry token list', as well as by its numeric ID. A name that several tokens share is refused with their IDs, so a destructive action never picks one of them.
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 9b573e8. Configure here.
The ID grammar read 'my-org/ci/2024' as a project and ID, so a token named 'ci/2024', which token create accepts, couldn't be revoked by name. Tokens have no project, so split at the first slash like create.
Older Sentry orgs can have underscores in their slug, so 'my_org/ci' named a token 'my_org/ci' in the default org instead of 'ci' in my_org.
BYK
approved these changes
Nov 4, 2026
7 tasks done
joshuawayzwright
pushed a commit
to joshuawayzwright/sentry-mcp
that referenced
this pull request
Nov 16, 2026
## Summary Bumps `@sentry/api` from 0.256.0 to 0.337.0. getsentry#1559 needs the issue-linking operations and the `expectedExternalIssueUrl` guard that ship in the newer schema; landing the bump on its own keeps that PR focused on the feature. No source changes were needed. The only regenerated file is the `event` skill reference, which now lists the `formatted` field the schema documents for `event view`. ## Validation - `tsc --noEmit` and lint pass. - Unit suite: 473 files, 10,092 passed / 17 skipped (`TZ=UTC`). Split out of getsentry#1559. Co-authored-by: Cursor <cursoragent@cursor.com>
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Adds
sentry token list,sentry token create, andsentry token deletefor org auth tokens (theorg:citokens used for source map, debug file, and release uploads).sentry tokensis an alias fortoken list. This is the CLI side of getsentry/sentry#128051, and replaces the archived getsentry/cli#1112.Scopes
Sentry only lets OAuth application tokens that hold
org:tokensmanage org auth tokens. Personal tokens, org tokens, andSENTRY_AUTH_TOKENget a 403. Here's what each endpoint requires, checked against the merged backend:org:tokens+org:readorg:tokens+org:read+org:ci(an OAuth caller can only mint scopes it holds)org:tokens+org:read+org:write(the delete isorg:write, the confirm lookup isorg:read)org:tokensis now inSENTRY_SCOPES, soauth login --scope org:tokensvalidates. I kept it out of the defaultOAUTH_SCOPESon purpose. The device flow rejects the whole request when it sees a scope it doesn't know, so addingorg:tokensto the defaults would breaksentry auth loginon older self-hosted servers.Instead, each token command calls
ensureScopesForAction, and it can now ask for scopes outside the defaults:requiredonly names default scopes, nothing changes: the device flow requests the defaults.required.When elevation is needed but this run can't do it (no TTY,
--yes, or--json), a 403 gets a specific explanation: what to run once interactively, or that the command needs a CLI login plus an org role that allows it.Notes for review
getControlSiloUrl(). They aren't in@sentry/api(checked 0.399.0), soOrgAuthTokenSchemais a Valibot schema that mirrors the backend serializer.createoutput, including--json, because Sentry can't return it again.listshows onlytokenLastCharacters.deletereads the list to show the token name in the confirmation, since there's no single-token GET. The list is unpaginated server-side.createsplitsorg/nameon the first/, but only when the prefix looks like an org slug. Names containing/work as long as the org is given explicitly.Tests
scope-recovery.typecheck,lint,check:docs-sections,check:destructive,check:fragments, andcheck:errorspass.mainin my sandbox, so they're environment issues unrelated to this change.via BYK.
--
View Junior Session in Sentry