-
Notifications
You must be signed in to change notification settings - Fork 0
02 authentication
Bucket Agent is multiprovider by design. It works without any authentication (local Ollama), with an API key, or with enterprise SSO. This guide explains all available options.
No account, no API key. Just configure a local model and go:
# ~/.bucket/config.toml
[models]
default = "ollama-coder"
[model.ollama-coder]
model = "qwen2.5-coder:latest"
base_url = "http://localhost:11434/v1"
name = "Qwen 2.5 Coder (Ollama)"ollama serve
ollama pull qwen2.5-coder:latest
bucketBucket detects non-xAI endpoints automatically and skips the login screen entirely.
For cloud providers or CI/CD environments:
# xAI
export BUCKET_API_KEY="bucket-..."
bucket
# Any provider (per-model config)# ~/.bucket/config.toml
[model.my-model]
model = "gpt-4o"
base_url = "https://api.openai.com/v1"
env_key = "OPENAI_API_KEY"If you have an xAI subscription and prefer browser-based SSO:
bucket loginBucket stores credentials in ~/.bucket/auth.json and reuses them across sessions. Tokens refresh automatically. To switch accounts or sign out:
bucket logout
bucket loginAuthenticate developers through your own Identity Provider (Okta, Azure AD, Auth0, etc.) instead of bucket.com.
- Grant type: Authorization Code with PKCE
- Redirect URI:
http://127.0.0.1/callback - No client secret (PKCE replaces it)
# ~/.bucket/config.toml
[bucket_com_config.oidc]
issuer = "https://acme.okta.com"
client_id = "0oa1b2c3d4e5f6g7h8i9"Or via environment variables:
export BUCKET_OIDC_ISSUER="https://acme.okta.com"
export BUCKET_OIDC_CLIENT_ID="0oa1b2c3d4e5f6g7h8i9"The CLI discovers endpoints via {issuer}/.well-known/openid-configuration, opens the IdP login page, and stores tokens in ~/.bucket/auth.json. Tokens auto-refresh via the stored refresh_token.
When browser-based login is impossible — sandboxed VMs, CI runners, air-gapped networks — delegate authentication to an external binary:
+----------------+ sh -c +-------------------------+
| Bucket Agent |------------>| your auth binary |
| | | |
| reads |<-- stdout --| prints token |
| auth.json | | |
| | (stderr) | prints status/URLs |--> surfaced to user
+----------------+ +-------------------------+
| Stream | What to print | Who sees it |
|---|---|---|
| stdout | The token — nothing else | Bucket (parsed and stored in auth.json) |
| stderr | Login URLs, status messages, errors | The user (shown as a clickable link in the TUI) |
Bare string:
eyJhbGciOiJSUzI1NiIs...
JSON (with optional refresh token, expiry, and issuer):
{"access_token": "eyJhbGciOi...", "refresh_token": "ref-tok", "expires_in": 3600, "issuer": "https://idp.example.com"}# ~/.bucket/config.toml
[auth]
auth_provider_command = "/usr/local/bin/my-auth-provider"
auth_provider_label = "Acme Corp" # optional — customizes the TUI login button
auth_token_ttl = 3600 # optional — token lifetime in secondsOr via environment variables:
export BUCKET_AUTH_PROVIDER_COMMAND="/usr/local/bin/my-auth-provider"
export BUCKET_AUTH_PROVIDER_LABEL="Acme Corp"
export BUCKET_AUTH_TOKEN_TTL=3600When Bucket needs to refresh an expired token, it re-runs your binary with BUCKET_AUTH_EXPIRED=1 set:
#!/bin/sh
if [ "$BUCKET_AUTH_EXPIRED" = "1" ]; then
echo "Refreshing token..." >&2
TOKEN=$(my-company-auth --refresh --silent)
else
echo "Authenticating via Acme Corp SSO..." >&2
TOKEN=$(my-company-auth --login --interactive)
fi
if [ -z "$TOKEN" ]; then
echo "Authentication failed" >&2
exit 1
fi
echo "{\"access_token\": \"$TOKEN\", \"expires_in\": 3600}"For headless environments (SSH, Docker, remote VMs) where no browser is available locally:
bucket login --device-auth # or: bucket login --device-codePrints a URL and code to the terminal. Open the URL on any device, enter the code, and complete authentication. Bucket polls until confirmed.
Bucket resolves credentials in this order, highest to lowest:
-
Per-model
api_keyorenv_key— set under[model.<name>]inconfig.toml. Wins whenever present. -
Active session token — from browser, OIDC, or external-provider login, stored in
~/.bucket/auth.json. -
BUCKET_API_KEY— fallback when no session token is active.
When more than one login flow is configured:
- External auth provider (
auth_provider_command) - Enterprise OIDC
- xAI/bucket.com OAuth2 browser login
| File | Contents |
|---|---|
~/.bucket/auth.json |
Stored session tokens (access + refresh) |
~/.bucket/config.toml |
Model and auth configuration |
Bucket picks up changes to ~/.bucket/auth.json automatically — no restart needed.
BUCKET_LOG_FILE=/tmp/bucket.log RUST_LOG=debug bucket
tail -f /tmp/bucket.logIn headless mode, logs go to stderr:
RUST_LOG=debug bucket -p "hello" 2> /tmp/bucket.log-
Login screen at startup — configure a local model or set
BUCKET_API_KEY; see Custom Models. -
Token expires too quickly — set
auth_token_ttlor returnexpires_inin your auth provider's JSON output. -
OIDC redirect fails — ensure your IdP allows loopback redirect URIs (
http://127.0.0.1/callback). -
External auth provider not found — check the
auth_provider_commandpath is correct and the binary is executable.