Authentication
Happy uses secure, device-based authentication to protect your AI sessions. Your master secret never leaves your mobile device or web browser - the CLI only receives a derived key for machine-specific encryption.Authentication Methods
Happy offers two authentication methods:- Mobile Authentication - Scan a QR code with the Happy mobile app
- Web Authentication - Authenticate through your web browser
happy auth login, you’ll be prompted to choose your preferred method.
Authentication Flow
Generate ephemeral key pair
The CLI creates a temporary cryptographic key pair using TweetNaCl for secure key exchange.
Create authentication request
The public key is sent to the Happy server at
/v1/auth/request with supportsV2: true flag.Display authentication prompt
Mobile: QR code containing
happy://terminal?<base64url-encoded-public-key>Web: Browser opens with authentication URL containing the public keyApprove on device
Complete authentication on your mobile device or in the browser. The server encrypts your credentials using the ephemeral public key.
Receive encrypted credentials
The CLI polls the server until authentication is approved, then decrypts the response using the ephemeral private key.
Authentication Commands
Login
Authenticate with Happy for the first time or re-authenticate:Force Re-authentication
Clear all credentials and re-authenticate from scratch:- Stop the daemon if running
- Clear existing credentials
- Clear machine ID
- Re-authenticate and register the machine
Check Status
View your current authentication status:Logout
Remove all authentication data and credentials:Logging out removes your entire
~/.happy/ directory and stops the daemon. This action cannot be undone.Security Details
End-to-End Encryption
Happy uses TweetNaCl (NaCl cryptography library) for all encryption:- Ephemeral key exchange: Temporary key pairs created for each authentication
- Box encryption: Public-key authenticated encryption for credential exchange
- No plaintext transmission: All sensitive data encrypted before leaving your device
Key Architecture
Credential Storage
Credentials are stored in:- Location:
~/.happy/(or$HAPPY_HOME_DIR/) - Files:
access.key(legacy) or newer data-key format - Permissions: Restricted to user-only access
- Format: Base64-encoded encrypted data
Authentication Types
Happy supports two credential formats:Legacy (32-byte secret)
Legacy (32-byte secret)
Older authentication method using a 32-byte shared secret:
Data Key (public-key cryptography)
Data Key (public-key cryptography)
Modern authentication using public-key cryptography:The server response includes a version byte (
0x00) prefix to indicate the data-key format.Troubleshooting
Browser didn’t open automatically
If you chose web authentication but the browser didn’t open:- Copy the URL displayed in the terminal
- Paste it into your browser manually
- Complete authentication in the browser
QR code not scanning
If the QR code won’t scan:- Ensure your terminal supports unicode characters
- Try increasing your terminal font size
- Use the manual URL shown below the QR code
- Switch to web authentication with
happy auth loginand select the web option
Authentication polling timeout
If authentication takes too long:- The CLI polls every 1 second for up to several minutes
- Press
Ctrl+Cto cancel and try again - Check your network connection to Happy servers
”Not authenticated” errors
If you see authentication errors:Backup codes not available
Backup codes and master secrets are only accessible from your mobile device or web account, not from the CLI. This is a security feature - each CLI machine only has a derived key, not the master secret.
Environment Variables
Customize authentication behavior:Related Commands
happy doctor- Diagnose authentication issueshappy daemon status- Check daemon authentication state