Skip to content

Commit 33ad867

Browse files
azulusclaude
andcommitted
feat(seer): Broaden Explorer API token scopes for write operations
Add org:write, project:write, event:write, alerts:read, alerts:write, member:read, and team:read scopes to the short-lived token. The agent needs write scopes to create dashboards, alerts, and other resources on behalf of the user. Token remains org-scoped and 1-hour expiry. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent edd2b98 commit 33ad867

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/sentry/seer/explorer/client_utils.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,12 +291,27 @@ def collect_user_org_context(
291291
try:
292292
from sentry.models.apitoken import ApiToken
293293
from sentry.types.token import AuthTokenType
294+
from sentry.users.models.user import User
295+
296+
# request.user may be an RpcUser proxy — ApiToken needs the real User model
297+
real_user = User.objects.get(id=user.id)
294298

295299
token = ApiToken.objects.create(
296-
user=user,
300+
user=real_user,
297301
token_type=AuthTokenType.USER,
298302
scoping_organization_id=organization.id,
299-
scope_list=["org:read", "project:read", "event:read"],
303+
scope_list=[
304+
"org:read",
305+
"org:write",
306+
"project:read",
307+
"project:write",
308+
"event:read",
309+
"event:write",
310+
"alerts:read",
311+
"alerts:write",
312+
"member:read",
313+
"team:read",
314+
],
300315
expires_at=timezone.now() + timedelta(hours=1),
301316
)
302317
user_auth_token = token.plaintext_token

0 commit comments

Comments
 (0)