CLI Authentication
Sprites uses your Fly.io account for authentication. This guide covers setting up authentication and managing API tokens.
Quick Setup
Section titled “Quick Setup”The simplest way to authenticate:
sprite org authThis opens a browser window to authenticate with Fly.io. Once complete, you’re ready to use Sprites.
Authentication Flow
Section titled “Authentication Flow”1. Authenticate with Fly.io
Section titled “1. Authenticate with Fly.io”If you’re already logged into flyctl, the Sprites CLI can use your existing session:
sprite org authIf you’re not logged in or encounter issues:
# First, ensure you're logged into flyfly auth logoutfly auth login
# Verify your flyctl session worksfly apps list
# Then authenticate with Spritessprite org auth2. Select an Organization
Section titled “2. Select an Organization”If you belong to multiple Fly.io organizations, select one:
sprite org listOutput:
Organizations: personal (current) my-team another-orgTo switch organizations:
sprite org auth --org my-teamToken Management
Section titled “Token Management”You can also create and manage tokens at sprites.dev/account.
Viewing Your Token
Section titled “Viewing Your Token”Your Sprites API token is stored securely. To view it:
# If using keyring storage, disable it firstsprite org keyring disable
# Then check the config filecat ~/.sprites/sprites.jsonThe token is used for API and SDK authentication.
Token Storage
Section titled “Token Storage”By default, tokens are stored in your system keyring for security. You can switch to file-based storage:
# Disable keyring (stores token in config file)sprite org keyring disable
# Re-enable keyring storagesprite org keyring enableConfig File Structure
Section titled “Config File Structure”When using file-based storage, ~/.sprites/sprites.json contains:
{ "version": "1", "current_selection": { "url": "https://api.sprites.dev", "org": "personal" }, "urls": { "https://api.sprites.dev": { "url": "https://api.sprites.dev", "orgs": { "personal": { "name": "personal", "keyring_key": "sprites-cli:<user-id>", "use_keyring": true, "sprites": {} } } } }}Multiple Organizations
Section titled “Multiple Organizations”Adding Organizations
Section titled “Adding Organizations”Add tokens for multiple organizations:
# Add another organizationsprite org auth --org my-teamSwitching Organizations
Section titled “Switching Organizations”# List organizationssprite org list
# Use a specific org for a commandsprite -o my-team list
# Set default organizationsprite org auth --org my-teamPer-Directory Organization
Section titled “Per-Directory Organization”Use different organizations in different directories:
cd ~/projects/team-projectsprite use --org my-team my-sprite
cd ~/projects/personalsprite use --org personal my-personal-spriteThe organization is saved in the local .sprite file.
Logging Out
Section titled “Logging Out”Remove a Single Organization
Section titled “Remove a Single Organization”sprite org logout --org my-teamRemove All Credentials
Section titled “Remove All Credentials”sprite logoutThis removes all stored tokens and configuration.
Environment Variables
Section titled “Environment Variables”For CI/CD or automated environments, you can use environment variables:
export SPRITE_TOKEN="spr_xxxxxxxxxxxxx"export SPRITES_API_URL="https://api.sprites.dev" # Optional, uses defaultSPRITE_TOKEN is used as a fallback when no stored token is available.
Troubleshooting
Section titled “Troubleshooting””Not authenticated” Error
Section titled “”Not authenticated” Error”# Re-authenticatesprite org auth
# If that fails, reset and try againfly auth logoutfly auth loginsprite org authToken Not Found
Section titled “Token Not Found”If the CLI can’t find your token:
# Check if using keyringsprite org keyring disable
# Verify token existscat ~/.sprites/sprites.json | grep api_token
# Re-authenticate if neededsprite org authBrowser Doesn’t Open
Section titled “Browser Doesn’t Open”If the authentication browser doesn’t open automatically:
- Look for the URL printed in the terminal
- Copy and paste it into your browser
- Complete authentication
- Return to the terminal
Permission Errors
Section titled “Permission Errors”If you get permission errors after authentication:
- Verify your Fly.io account has access to the organization
- Check that your
flyctlsession is valid:fly apps list - Try re-authenticating:
sprite org auth
Security Best Practices
Section titled “Security Best Practices”- Use keyring storage (default) for interactive use
- Use environment variables for CI/CD pipelines
- Never commit
.sprites/or.spritefiles to version control - Rotate tokens periodically by re-authenticating
- Use organization-specific tokens rather than personal tokens in shared environments
Next Steps
Section titled “Next Steps”- Commands Reference - Full CLI documentation
- Quickstart - Create your first Sprite