Authentication
The CLI needs to know who you are. You can log in as yourself for local development, or use project tokens for automation.
How It Works
Vizzly CLI supports two ways to authenticate:
OAuth Login - Best for local development. Log in once, work on any project. The CLI handles token refresh automatically.
Project Tokens - Best for CI/CD. Direct token authentication, no user session needed.
Logging In
vizzly loginThis starts an OAuth device flow. Here’s what happens:
- The CLI generates a device code
- Your browser opens to
https://app.vizzly.dev/auth/devicewith the code pre-filled - You authorize the CLI with your Vizzly account
- Press Enter in the terminal
- You’re in
The CLI stores your tokens in ~/.vizzly/config.json with secure permissions (owner read/write only). Tokens refresh automatically when they’re about to expire - you won’t even notice.
Get JSON output:
vizzly login --jsonChecking Who You Are
vizzly whoamiShows your current user, organizations, and token expiry. Useful for confirming you’re logged in correctly.
Example:
Authenticated
User: Jane DeveloperEmail: jane@example.com
Organizations: - Acme Inc (@acme) - Personal (@jane)
Token expires in 29 days (2025-12-15)Get JSON output:
vizzly whoami --jsonLogging Out
vizzly logoutRevokes your tokens on the server and clears them locally. Your project mappings (from vizzly project:select) stay intact.
Project-Specific Tokens
If you work on multiple projects, you can map specific tokens to directories. The CLI automatically uses the right token based on where you are.
Selecting a Project
cd /path/to/projectvizzly project:selectThis walks you through:
- Choose an organization
- Choose a project
- The CLI creates a new project token automatically and saves it for this directory
The token gets stored in ~/.vizzly/config.json mapped to your current directory path. The CLI walks up the directory tree to find the closest mapping, so subdirectories inherit the token.
Listing Project Mappings
vizzly project:listShows all configured projects:
Project mappings: /Users/jane/acme-app → Acme Inc / Marketing Site /Users/jane/personal → Personal / Landing PageShowing the Current Token
vizzly project:tokenDisplays the first 10 characters of the project token for the current directory.
Get the full token:
vizzly project:token --jsonRemoving a Project
vizzly project:removeDeletes the project mapping for the current directory.
Using Tokens Directly
For CI/CD or automated environments, skip OAuth and use project tokens directly.
Environment Variable
export VIZZLY_TOKEN=vzt_your_project_token_herevizzly run "npm test"CLI Flag
vizzly run "npm test" --token vzt_your_project_token_here.env File (Local Only)
Create a .env file in your project root:
VIZZLY_TOKEN=vzt_your_project_token_hereImportant: Add .env to .gitignore. Never commit tokens.
CI/CD Examples
Use your CI provider’s secret manager:
GitHub Actions:
- name: Run visual tests run: npx vizzly run "npm test" --wait env: VIZZLY_TOKEN: ${{ secrets.VIZZLY_TOKEN }}GitLab CI:
visual-tests: script: - npx vizzly run "npm test" --wait variables: VIZZLY_TOKEN: $VIZZLY_TOKENCircleCI:
- run: name: Visual tests command: npx vizzly run "npm test" --wait environment: VIZZLY_TOKEN: $VIZZLY_TOKENToken Resolution
The CLI looks for tokens in this order:
--tokenflag (highest priority)VIZZLY_TOKENenvironment variable- Project mapping (from
vizzly project:select) - User access token (from
vizzly login)
This lets you override authentication for specific commands while keeping defaults for regular use.
Examples:
# Override with flagvizzly run "npm test" --token vzt_different_token
# Use project mappingcd /path/to/projectvizzly run "npm test"
# Fallback to user tokenvizzly logincd /new/projectvizzly run "npm test"Advanced Configuration
Custom config location:
Set VIZZLY_HOME to change where the CLI stores authentication:
export VIZZLY_HOME=/custom/pathvizzly loginUseful for isolating dev and production configs, or running tests.
Troubleshooting
Authentication fails with “Invalid or expired API token”
If you’re using vizzly login, the token should refresh automatically. If it doesn’t:
vizzly logoutvizzly loginIf you’re using VIZZLY_TOKEN or a project mapping, the token might be expired or invalid. Generate a new project token from the Vizzly dashboard.
Project token not being used
Check your project mappings:
vizzly project:listThe CLI walks up the directory tree to find mappings. If you’re in /Users/jane/project/src, it will look for mappings in:
/Users/jane/project/src/Users/jane/project/Users/jane/Users
If nothing matches, it falls back to environment variables or user tokens.
”Not authenticated” error
You need to either:
vizzly loginOr set a token:
export VIZZLY_TOKEN=vzt_your_project_tokenSecurity
- Never commit tokens - Add
.envto.gitignore - Use CI secrets - Store
VIZZLY_TOKENin your provider’s secret manager - Tokens auto-refresh - User tokens refresh transparently, no manual intervention needed
- Secure storage - Local tokens are stored with
0o600permissions (owner-only access)