Overview
Loom CLI uses OAuth2 device code flow for secure, user-friendly authentication. This method is ideal for command-line tools as it doesn’t require embedding client secrets or handling browser redirects.Authentication Flow
Device Code Flow
Commands
login
Authenticate with Loom services.Loom server URL to authenticate againstExample:
https://loom.ghuntley.com- CLI initiates device code flow with server
- Server generates:
device_code: Secret code for polling (not shown to user)user_code: Short code for user to enter (e.g., “ABCD-1234”)verification_url: URL where user authorizesexpires_in: Timeout in seconds (typically 300-600)
- CLI displays verification URL and user code
- CLI attempts to open URL in default browser
- CLI polls server every 1 second until:
- User completes authorization → receives access token
- Flow expires → returns error
- User cancels with Ctrl+C → aborts
- Access token is stored securely
logout
Log out and clear credentials.Loom server URL to log out from
- CLI loads stored token for the server URL
- Calls
POST /auth/logoutwith token to invalidate server-side - Deletes token from local credential store
- Token can no longer be used for API calls
Credential Storage
Storage Strategy
Loom uses a keyring-first, file-fallback strategy:- Primary: System Keyring
- macOS: Keychain
- Windows: Credential Manager
- Linux: Secret Service (libsecret, gnome-keyring, KWallet)
- Fallback: Encrypted File
- Location:
~/.config/loom/credentials.json - Used when keyring is unavailable
- Permissions:
0600(owner read/write only)
- Location:
Credential Format
Credentials are stored per-server using a sanitized server key:Security Features
- Keyring Integration: Leverages OS-level secure storage
- File Permissions: Restrictive permissions on fallback file
- Token Redaction: Tokens are never logged or displayed
- Server Isolation: Each server’s credentials are stored separately
Multiple Servers
You can authenticate with multiple Loom servers:Token Management
Token Lifecycle
Token Expiration
Loom access tokens may expire after a period (configured server-side). When a token expires:- API calls return
401 Unauthorized - CLI displays authentication error
- Run
loom loginagain to obtain a new token
Token Inspection
Tokens are opaque strings and should not be inspected or manipulated manually.Error Handling
Common Errors
Browser Failed to Open:loom login again. Complete authorization faster (typically 5-10 minute window).
Network Error:
- Verify server URL is correct
- Check network connectivity
- Ensure server is running
Troubleshooting Authentication
Check Server Connectivity:Advanced Usage
Environment Variable
Set default server URL:Programmatic Access
Theloom-cli-credentials crate can be used in other Rust programs:
Git Credential Helper
Loom can act as a git credential helper for authenticated git operations:loom credential-helper --help for details.
Security Best Practices
Do’s
- ✅ Use strong, unique passwords for your Loom account
- ✅ Log out from shared/public computers
- ✅ Keep your system’s keyring/credential manager secure
- ✅ Regularly update Loom CLI to latest version
- ✅ Use different accounts for different environments (prod/staging)
Don’ts
- ❌ Never share your access token
- ❌ Never commit credentials.json to version control
- ❌ Never use same token on multiple machines (login separately)
- ❌ Never set overly permissive file permissions on credentials.json
- ❌ Never disable certificate validation in production
Internationalization
Authentication messages are localized based on system locale: English (en):- English (en)
- Spanish (es)
- Arabic (ar)
Related Pages
CLI Overview
Main CLI commands and setup
REPL Commands
Interactive session after authentication