Authentication
Set up authentication for the Riven CLI, CI pipelines, and multi-org workflows.
Overview
The Riven CLI supports multiple authentication methods depending on your environment. For local development, use the browser-based login flow. For CI/CD pipelines, use a RIVEN_TOKEN environment variable.
Browser Login
The primary authentication method for local development. Running riven auth login starts a local server and opens your browser to complete OAuth sign-in:
riven auth loginStarting local auth server on port 9876...
Opening browser for authentication...
✓ Logged in as [email protected] (org: riven-ai)
Credentials saved to ~/.config/riven/credentials.jsonThe browser navigates to app.riven-ai.dev/auth/cli?port=9876, where you sign in with your Riven account. Once authenticated, a platform JWT is issued and sent back to the local server.
Verify Your Session
Check your current authentication status at any time:
riven auth statusAuthenticated as: [email protected]
Organization: riven-ai
Token expires: 2026-03-22T04:00:00ZLog Out
To clear your stored credentials:
riven auth logoutCI/CD Token
For non-interactive environments like CI/CD pipelines, set the RIVEN_TOKEN environment variable. This bypasses the browser login flow entirely.
Generate a token from the Riven dashboard under Settings > API Keys, or use the CLI:
riven auth token --scope ci --expires 90dToken created successfully.
RIVEN_TOKEN=rt_ci_xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Expires: 2026-06-19T00:00:00ZThen set it in your CI environment:
env:
RIVEN_TOKEN: ${{ secrets.RIVEN_TOKEN }}export RIVEN_TOKEN=$RIVEN_TOKEN
riven deployToken Storage
Credentials from riven auth login are stored at:
~/.config/riven/credentials.jsonThe file contains the JWT token, your user ID, organization ID, and expiration timestamp. The CLI refreshes the token automatically when it is close to expiring.
Never share or commit your credentials file. It is excluded from git by default, but make sure ~/.config/riven/ is not synced to cloud storage.
Token Resolution Order
When the CLI needs to authenticate, it checks for credentials in this order:
- CLI flag —
--token <value>passed directly to the command. - Environment variable —
RIVEN_TOKENset in the current shell. - Credentials file —
~/.config/riven/credentials.jsonfrom a previousriven auth login. - Project config —
riven.config.tswith an inline token (not recommended).
The first source that provides a valid token wins. This lets you override credentials per-command or per-environment without changing your global config.
Multi-Org Support
If you belong to multiple organizations, you can switch between them:
# List your organizations
riven auth orgs
# Switch to a different org
riven auth login --org-id other-orgAvailable organizations:
riven-ai (current)
other-org
staging-org
Switching to other-org...
✓ Logged in as [email protected] (org: other-org)You can also set RIVEN_ORG_ID in your environment to target a specific org without re-authenticating:
RIVEN_ORG_ID=staging-org riven deployThis is useful in CI pipelines where you deploy to multiple orgs from the same workflow.