You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GET /api/0/auth/ returns 400 Bad Request when called with a valid Authorization: Bearer <token> header. The token is valid — Django middleware successfully resolves it (visible as DB spans in the trace) — but DRF's authentication pipeline does not recognize it because BaseAuthIndexEndpoint overrides authentication_classes to exclude UserAuthTokenAuthentication.
Root Cause
In src/sentry/api/endpoints/auth_index.py line 50:
This excludes UserAuthTokenAuthentication (which handles Bearer tokens) and OrgAuthTokenAuthentication. When the CLI sends Authorization: Bearer <oauth-token>:
QuietBasicAuthentication.authenticate() — sees "Bearer" (not "Basic") → returns None
SessionAuthentication.authenticate() — no session cookie → returns None
The token DB lookups visible in the trace are from Django middleware before DRF's pipeline — DRF doesn't carry them over (no __from_api_client__ flag).
Impact
This affects external API clients using Bearer token auth to call GET /api/0/auth/. The Sentry CLI uses this endpoint for the sentry auth whoami command.
In practice, the CLI's response cache often masks this — users see the bug only on cache misses or first-time calls.
UserAuthTokenAuthentication should come first so Bearer tokens are resolved before falling through to basic/session auth.
Secondary issue
Org-scoped tokens would still fail because /api/0/auth/ (sentry-api-0-auth) is not in the org-endpoint allowlist checked by UserAuthTokenAuthentication.authenticate_token(). That URL name may also need to be added to the allowlist for full compatibility.
Activity
linear-code commentedon Apr 13, 2026
ENG-7320
fix(api): Allow Bearer token auth for GET /api/0/auth/ (#112853)