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
feat(auth): auto-trigger login flow when authentication required (#170)
## Summary
When a command requires authentication but the user isn't logged in,
automatically start the OAuth device flow instead of showing an error.
After successful login, the original command retries automatically.
Only triggers in interactive TTY environments - non-TTY sessions (CI,
scripts, piped input) continue showing the error message as before.
## Changes
- Extract device flow UI logic into `src/lib/interactive-login.ts` for
reuse
- Refactor `auth login` command to use the shared helper
- Add `executeWithAutoAuth()` wrapper in `bin.ts` that catches
`AuthError("not_authenticated")` and triggers login
## Test Plan
1. Log out: `sentry auth logout`
2. Run a command that requires auth: `sentry issue list`
3. Should see "Authentication required. Starting login flow..." and the
OAuth device flow starts
4. Complete login in browser
5. Original command should automatically retry and succeed
**Non-TTY test:**
```bash
echo "" | sentry issue list
# Should show: "Error: Not authenticated. Run 'sentry auth login' first."
```
0 commit comments