> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trilo.chat/llms.txt
> Use this file to discover all available pages before exploring further.

# Authentication

> Authenticate the Trilo CLI with browser OAuth login or Personal Access Tokens for CI/CD

The CLI supports two authentication methods: browser-based OAuth login (for interactive use) and Personal Access Tokens (for CI/CD and automation).

## Browser Login (OAuth)

The simplest way to authenticate:

```bash theme={null}
trilo login
```

This will:

1. Open your browser to the Trilo authorization page
2. Ask you to approve CLI access to your workspace
3. Store your token securely in `~/.config/trilo/credentials.json`
4. Auto-select your workspace (or prompt you to choose if you have multiple)

Tokens are automatically refreshed when they expire — you should only need to run `trilo login` once.

To log out and clear stored credentials:

```bash theme={null}
trilo logout
```

## Personal Access Tokens (PAT)

For CI/CD pipelines, scripts, and automation, use a Personal Access Token:

1. Go to **Settings > Tokens** in the Trilo web app
2. Create a new token with the scopes you need
3. Set it as an environment variable:

```bash theme={null}
export TRILO_TOKEN="trilo_pat_xxx"
```

Or write it to the config file:

```bash theme={null}
mkdir -p ~/.config/trilo
echo '{"token":"trilo_pat_xxx","url":"https://api.trilo.chat"}' > ~/.config/trilo/credentials.json
chmod 600 ~/.config/trilo/credentials.json
```

<Warning>
  PAT tokens provide persistent access to your workspace. Store them securely and rotate them periodically. Never commit tokens to version control.
</Warning>

## Workspace Selection

After authenticating, set your default workspace:

```bash theme={null}
# List available workspaces
trilo workspace list

# Set default workspace
trilo workspace set <workspace-id>

# Check current workspace
trilo workspace current
```

You can also override the workspace per-command:

```bash theme={null}
trilo tasks list --workspace <other-workspace-id>
```

## Environment Variables

| Variable             | Description                      | Default                  |
| -------------------- | -------------------------------- | ------------------------ |
| `TRILO_TOKEN`        | Override stored token            | —                        |
| `TRILO_API_URL`      | API endpoint URL                 | `https://api.trilo.chat` |
| `TRILO_FRONTEND_URL` | Frontend URL (for `trilo login`) | `https://app.trilo.chat` |

## Configuration Files

All config is stored in `~/.config/trilo/` (respects `XDG_CONFIG_HOME`):

| File               | Contents                             | Permissions         |
| ------------------ | ------------------------------------ | ------------------- |
| `credentials.json` | Access token, refresh token, API URL | `0600` (owner-only) |
| `config.json`      | Default workspace ID and name        | `0600` (owner-only) |

## CI/CD Example

```yaml theme={null}
# GitHub Actions example
jobs:
  create-task:
    runs-on: ubuntu-latest
    steps:
      - name: Create deployment task
        env:
          TRILO_TOKEN: ${{ secrets.TRILO_PAT }}
        run: |
          bunx trilo tasks create \
            --title "Deploy ${{ github.sha }}" \
            --project-id ${{ vars.TRILO_PROJECT_ID }} \
            --status in_progress \
            --priority high
```
