Authentication Methods
The Rexec CLI supports two authentication methods:- Browser-based OAuth - Interactive login with browser
- API Token - Direct authentication with token
Browser-Based Login
The recommended method for interactive users.Step 1: Start Login Flow
- Start a local callback server on port 9876
- Open your default browser
- Redirect to Rexec login page
- Wait for authentication
Step 2: Complete in Browser
- Login or signup to Rexec
- Authorize CLI access
- Browser shows “Login Successful!”
- Return to terminal
Step 3: Verify Success
Timeout and Errors
The login flow times out after 5 minutes. If you encounter issues:API Token Authentication
Generate an API Token
- Login to Rexec Dashboard
- Navigate to Settings → API Tokens
- Click Generate New Token
- Copy the token (starts with
rexec_)
Login with Token
Token Types
Rexec supports two token types:JWT Tokens (Browser Login)
- Generated during OAuth flow
- Short-lived (configurable expiration)
- Stored in
~/.rexec/config.json - Format: Standard JWT (3 base64 segments)
API Tokens
- Generated in dashboard settings
- Long-lived (no expiration by default)
- Prefixed with
rexec_ - Validated via
/api/tokens/validateendpoint
Configuration Storage
Authentication data is stored in~/.rexec/config.json:
File Permissions
The config file has restricted permissions for security:File permissions are
0600 (owner read/write only) to protect your credentials.Environment Variables
Override config file values with environment variables:- Environment variables (highest)
- Config file
- Default values (lowest)
Check Authentication Status
Verify you’re logged in:Logout
Clear stored credentials:~/.rexec/config.json completely.
Re-authentication
If your token expires or becomes invalid:Multiple Accounts
To switch between accounts:Security Best Practices
Protect Your Token
Protect Your Token
Do:
- Store tokens securely
- Use environment variables in CI/CD
- Rotate tokens periodically
- Use short-lived tokens in production
- Commit tokens to version control
- Share tokens via insecure channels
- Use the same token across multiple machines
- Store tokens in plain text scripts
CI/CD Authentication
CI/CD Authentication
For automated pipelines, use API tokens via environment variables:
Shared Machines
Shared Machines
Troubleshooting
Port 9876 Already in Use
If the callback server can’t start:- Stop any service using port 9876
- Use manual token login:
rexec login --token YOUR_TOKEN
Browser Doesn’t Open
If the browser doesn’t auto-open:- Copy the URL from the terminal
- Manually open in browser:
Invalid Token Error
- Token expired
- Token revoked in dashboard
- Wrong API host
Configuration File Corrupted
If config file is corrupted:API Endpoints
The CLI uses these authentication endpoints:| Endpoint | Method | Purpose |
|---|---|---|
/cli-login | GET | Browser OAuth flow |
/api/profile | GET | Get user profile (JWT) |
/api/tokens/validate | GET | Validate API token |
Token Format
JWT Token
- Header (algorithm + type)
- Payload (user data + expiration)
- Signature (verification)
API Token
- Prefix:
rexec_ - Length: 40-64 characters
- Characters: alphanumeric
Next Steps
CLI Commands
Explore all available CLI commands
TUI Dashboard
Launch interactive terminal UI