11# Development Guide
22
3- This guide explains how to develop and test the Sentry CLI and OAuth proxy locally.
4-
53## Prerequisites
64
75- [ Bun] ( https://bun.sh/ ) installed
@@ -11,8 +9,6 @@ This guide explains how to develop and test the Sentry CLI and OAuth proxy local
119
1210```
1311sentry-cli-next/
14- ├── apps/
15- │ └── oauth-proxy/ # Hono server for device flow OAuth
1612└── packages/
1713 └── cli/ # The Sentry CLI
1814```
@@ -25,75 +21,54 @@ sentry-cli-next/
2521bun install
2622```
2723
28- 2 . Create a ` .env ` file in the project root:
24+ 2 . Create a ` .env.local ` file in the project root:
2925
3026```
3127SENTRY_CLIENT_ID=your-sentry-oauth-client-id
32- SENTRY_CLIENT_SECRET=your-sentry-oauth-client-secret
3328```
3429
35- Get these from your Sentry OAuth application settings.
36-
37- ## Running Locally
38-
39- Open two terminal windows:
30+ Get the client ID from your Sentry OAuth application settings.
4031
41- ** Terminal 1 - OAuth Proxy: **
32+ ** Note: ** No client secret is needed - the CLI uses OAuth 2.0 Device Authorization Grant (RFC 8628) which is designed for public clients.
4233
43- ``` bash
44- cd apps/oauth-proxy
45- bun run dev
46- ```
47-
48- This starts the proxy on ` http://127.0.0.1:8723 ` (matching your Sentry OAuth app's redirect URI).
49-
50- ** Terminal 2 - CLI:**
34+ ## Running Locally
5135
5236``` bash
5337cd packages/cli
54- SENTRY_OAUTH_PROXY_URL=http://127.0.0.1:8723 bun run src/bin.ts auth login
38+ bun run --env-file=../../.env.local src/bin.ts auth login
5539```
5640
5741## Testing the Device Flow
5842
59- 1 . Start the OAuth proxy (see above)
60-
61- 2 . Run the CLI login command:
43+ 1 . Run the CLI login command:
6244
6345``` bash
6446cd packages/cli
65- SENTRY_OAUTH_PROXY_URL=http://127.0.0.1:8723 bun run src/bin.ts auth login
47+ bun run --env-file=../../.env.local src/bin.ts auth login
6648```
6749
68- 3 . You'll see output like:
50+ 2 . You'll see output like:
6951
7052```
7153Starting authentication...
7254
73- To authenticate, visit:
74- http://127.0.0.1:8723/device/authorize
75-
76- And enter code: ABCD-1234
55+ Opening browser...
56+ If it doesn't open, visit: https://sentry.io/oauth/device/
57+ Code: ABCD-EFGH
7758
78- Waiting for authorization (press Ctrl+C to cancel) ...
59+ Waiting for authorization...
7960```
8061
81- 4 . Open the URL in your browser and enter the code
82-
83- 5 . You'll be redirected to Sentry to authorize
84-
85- 6 . After authorizing, the CLI will receive the token and save it
62+ 3 . The browser will open to Sentry's device authorization page
63+ 4 . Enter the code and authorize the application
64+ 5 . The CLI will automatically receive the token and save it
8665
8766## Sentry OAuth App Configuration
8867
89- When creating your Sentry OAuth application, set:
90-
91- - ** Redirect URI** :
68+ When creating your Sentry OAuth application:
9269
93- - For local development: ` http://127.0.0.1:8723/callback `
94- - For production: ` https://your-vercel-app.vercel.app/callback `
95-
96- - ** Scopes** : Select the scopes your CLI needs:
70+ - ** Redirect URI** : Not required for device flow
71+ - ** Scopes** : The CLI requests these scopes:
9772 - ` project:read ` , ` project:write `
9873 - ` org:read `
9974 - ` event:read ` , ` event:write `
@@ -102,28 +77,25 @@ When creating your Sentry OAuth application, set:
10277
10378## Environment Variables
10479
105- ### OAuth Proxy
106-
107- | Variable | Description |
108- | ---------------------- | ------------------------------ |
109- | ` SENTRY_CLIENT_ID ` | Sentry OAuth app client ID |
110- | ` SENTRY_CLIENT_SECRET ` | Sentry OAuth app client secret |
80+ | Variable | Description | Default |
81+ | ------------------ | ------------------------------------ | -------------------- |
82+ | ` SENTRY_CLIENT_ID ` | Sentry OAuth app client ID | (required) |
83+ | ` SENTRY_URL ` | Sentry instance URL (for self-hosted)| ` https://sentry.io ` |
11184
112- ### CLI
85+ ## Building
11386
114- | Variable | Description | Default |
115- | ------------------------ | --------------- | ------------------------------ |
116- | ` SENTRY_OAUTH_PROXY_URL ` | OAuth proxy URL | ` https://sry-oauth.vercel.app ` |
87+ ``` bash
88+ cd packages/cli
89+ bun run build
90+ ```
11791
118- ## Deploying the OAuth Proxy
92+ ## Architecture
11993
120- ``` bash
121- cd apps/oauth-proxy
122- bunx vercel
94+ The CLI uses the OAuth 2.0 Device Authorization Grant ([ RFC 8628] ( https://datatracker.ietf.org/doc/html/rfc8628 ) ) for authentication. This flow is designed for CLI tools and other devices that can't easily handle browser redirects:
12395
124- # Set environment variables in Vercel dashboard or via CLI:
125- bunx vercel env add SENTRY_CLIENT_ID
126- bunx vercel env add SENTRY_CLIENT_SECRET
127- ```
96+ 1 . CLI requests a device code from Sentry
97+ 2 . User is shown a code and URL to visit
98+ 3 . CLI polls Sentry until the user authorizes
99+ 4 . CLI receives access token and stores it locally
128100
129- After deployment, update the default ` OAUTH_PROXY_URL ` in ` packages/cli/src/lib/oauth.ts ` to your Vercel URL .
101+ No proxy server is needed - the CLI communicates directly with Sentry .
0 commit comments