Authentication
The kdx CLI supports multiple authentication methods to connect to Kodexa environments.Authentication Methods
| Method | Use Case |
|---|---|
| OAuth Login | Interactive browser-based login |
| Device Code | Headless/server environments |
| API Key | Automation and CI/CD |
| Environment Variables | Container deployments |
OAuth Login (Recommended)
Thekdx login command provides browser-based OAuth authentication.
Flags
| Flag | Default | Description |
|---|---|---|
--profile | default | Profile name to save credentials |
--device | false | Use device-code flow (no browser) |
--no-browser | false | Print login URL instead of opening browser |
--timeout | 180 | Seconds to wait for login completion |
Examples
How It Works
- CLI opens your default browser to the Kodexa login page
- You authenticate with your credentials
- Browser redirects back to CLI with authentication token
- CLI saves the token to your profile
Device Code Flow
For environments without a browser (servers, containers, SSH sessions), use device-code authentication:How It Works
- CLI displays a code and URL
- You visit the URL on any device and enter the code
- CLI polls for completion and saves the token
API Key Authentication
For automation and CI/CD, you can use API keys directly.Creating an API Key
- Log in to your Kodexa environment
- Navigate to Settings → API Keys
- Click Create API Key
- Copy the generated key (shown only once)
Using API Keys
Option 1: Save to Profile
Option 2: Command Line Flag
Option 3: Environment Variables
Environment Variables
For containerized deployments and CI/CD, environment variables provide flexible authentication:| Variable | Description |
|---|---|
KODEXA_URL | Kodexa platform URL |
KODEXA_ACCESS_TOKEN | API key or OAuth token |
Example: GitHub Actions
Example: Docker
Profile Configuration
Profiles store authentication credentials locally for easy switching between environments.Profile Location
Credentials are stored in~/.kodexa/config.yaml:
Managing Profiles
Authentication Priority
When multiple authentication methods are configured, kdx uses this priority:--api-keycommand line flag--profilecommand line flagKODEXA_ACCESS_TOKENenvironment variable- Current profile in config file
Security Best Practices
API Key Security
- Never commit API keys to version control
- Use environment variables in CI/CD
- Rotate keys periodically
- Use minimal permissions for automation keys
Profile Security
- Profile config is stored with user-only permissions (
600) - Consider using credential helpers for sensitive environments
- Use separate profiles for production vs development
Token Expiration
- OAuth tokens may expire; re-run
kdx loginto refresh - API keys don’t expire unless revoked
- Check token validity with
kdx get projects(quick test)
Troubleshooting
Authentication Failed
- Verify the URL is correct
- Check if API key is valid and not revoked
- Try
kdx loginto refresh OAuth token
Profile Not Found
- List profiles with
kdx config list-profiles - Create profile with
kdx loginorkdx config set-profile
Browser Doesn’t Open
- Use
--no-browserflag and open URL manually - Use
--deviceflag for device-code flow - Check if
xdg-open(Linux) oropen(macOS) is available
Timeout During Login
- Increase timeout with
--timeout 300 - Ensure you complete browser authentication before timeout
- Check network connectivity to Kodexa server
