Skip to content
Docs GitHub

auth

Authenticate with Sentry

Authenticate with Sentry

Options:

OptionDescription
--token <token>Authenticate using an API token instead of OAuth
--timeout <timeout>Timeout for OAuth flow in seconds (default: 900)
--forceRe-authenticate without prompting
--url <url>Sentry instance URL to authenticate against (e.g. https://sentry.example.com). Required for self-hosted; defaults to SaaS (https://sentry.io).

Log out of Sentry

Refresh your authentication token

Options:

OptionDescription
--forceForce refresh even if token is still valid

View authentication status

Options:

OptionDescription
--show-tokenShow the stored token (masked by default)
-f, --freshBypass cache, re-detect projects, and fetch fresh data

Print the stored authentication token

Show the currently authenticated identity

Options:

OptionDescription
-f, --freshBypass cache, re-detect projects, and fetch fresh data

All commands support --json for machine-readable output and --fields to select specific JSON fields.

Terminal window
sentry auth login
  1. A URL and device code will be displayed
  2. Open the URL in your browser
  3. Enter the code when prompted
  4. Authorize the application
  5. The CLI automatically receives your token
Terminal window
sentry auth login --token YOUR_SENTRY_API_TOKEN

The --url flag is required when first connecting to a self-hosted instance. This registers the host as trusted so subsequent commands don't need the flag:

Terminal window
# OAuth login to a self-hosted instance (requires --url on first use)
sentry auth login --url https://sentry.example.com
# Token-based auth with self-hosted
sentry auth login --token YOUR_TOKEN --url https://sentry.example.com

See Self-Hosted Sentry for details.

Terminal window
# Force re-authentication (skip "already logged in" prompt)
sentry auth login --force
# Set a custom timeout for the OAuth flow (default: 900 seconds)
sentry auth login --timeout 300
Terminal window
sentry auth logout
Terminal window
sentry auth refresh
Terminal window
sentry auth token
Terminal window
sentry auth status
Authenticated as: username
Organization: my-org
Token expires: 2024-12-31
Terminal window
# Show the raw token
sentry auth status --show-token
# View current user
sentry auth whoami

Auth tokens are stored in a SQLite database at ~/.sentry/cli.db with restricted file permissions.

By default, the CLI checks for auth tokens in the following order:

  1. The stored OAuth token in the SQLite database (from sentry auth login)
  2. SENTRY_AUTH_TOKEN environment variable
  3. SENTRY_TOKEN environment variable (legacy alias)

The stored OAuth token takes priority because it supports automatic refresh. To override this and force environment tokens to win, set SENTRY_FORCE_ENV_TOKEN=1.

When a token comes from an environment variable, the CLI skips expiry checks and automatic refresh.