Monorepo for Aesthetic.Computer
aesthetic.computer
1# Device Code Flow Setup for CLI Authentication
2
3## Current Status
4
5✅ Implemented Device Code Flow in `ac-login.mjs`
6❌ Auth0 client needs configuration update
7
8## Required Auth0 Configuration
9
10### Enable Device Code Grant Type
11
121. Visit Auth0 Dashboard: https://manage.auth0.com/dashboard/us/aesthetic/applications
132. Find application: `LVdZaMbyXctkGfZDnpzDATB5nR0ZhmMt`
143. Go to **Settings** → **Advanced Settings** → **Grant Types**
154. Check the box for **Device Code**
165. Click **Save Changes**
17
18## Why Device Code Flow?
19
20Device Code Flow is perfect for CLI tools because:
21
22- ✅ **No localhost required** - works in containers, SSH sessions, etc.
23- ✅ **No callback URL** - user authenticates on any device
24- ✅ **Production-ready** - can ship to any user
25- ✅ **Better UX** - shows simple code to enter in browser
26
27## How It Works
28
291. CLI requests a device code from Auth0
302. Auth0 returns:
31 - `user_code` (e.g., "ABCD-EFGH")
32 - `verification_uri` (e.g., "https://auth0.com/activate")
33 - `device_code` (internal token for polling)
343. CLI displays code and URL to user
354. User visits URL on any device (phone, browser, etc.)
365. User enters the code and logs in
376. CLI polls Auth0 every 5 seconds
387. Once user completes auth, CLI receives tokens
398. Tokens saved to `~/.ac-token`
40
41## Testing After Configuration
42
43```bash
44# Login
45node ac-login.mjs
46
47# Check status
48node ac-login.mjs status
49
50# View token
51node ac-login.mjs token
52
53# Logout
54node ac-login.mjs logout
55```
56
57## Alternative: Keep Authorization Code Flow
58
59If you can't enable Device Code Flow, we can use the Authorization Code Flow with the hosted callback endpoint we created:
60
61- `/api/auth/cli-callback` endpoint exists
62- User needs to add `https://aesthetic.computer/api/auth/cli-callback` to Auth0 allowed callbacks
63- Requires `AUTH0_CLIENT_SECRET` environment variable in Netlify
64
65Device Code Flow is cleaner for CLI usage, but both work!