# Install the CLI and sign in

The `ohauthcat` CLI supports browser and device sign-in, named profiles and logout. Install it with one command, then [sign in](#browser-or-device-login).

## Install

**curl**

```sh wrap
curl -fsSL https://ohauthcat.com/install.sh | sh
```

The script picks the build for your OS and CPU (amd64 or arm64), checks it against the release's SHA-256 checksums and stops on any mismatch. When `cosign` is installed it also verifies the signature of the checksum file with the OhAuthCat public key, and stops if that fails. It installs to `/usr/local/bin` when that is writable, otherwise to `~/.local/bin`, and never runs `sudo`. Set `OHAUTHCAT_INSTALL_DIR` to choose the folder and `OHAUTHCAT_VERSION` (for example `1.2.3`) to pin a version.

**brew**

```sh
brew install ohauthcat/tap/ohauthcat
```

Update later with `brew upgrade ohauthcat`.

**PowerShell**

```powershell wrap
irm https://ohauthcat.com/install.ps1 | iex
```

Run it in PowerShell 5.1 or later. It installs `ohauthcat.exe` to `%LOCALAPPDATA%\Programs\ohauthcat` and adds that folder to your user `Path`, without administrator rights; open a new terminal afterwards. Windows builds exist for x64 only; on Arm use npm.

**npm**

```sh
npx @ohauthcat/cli --help
```

`npx` runs the CLI without installing it. For the `ohauthcat` command everywhere, run `npm install -g @ohauthcat/cli`. The package downloads the matching binary and verifies its checksum before running it.

Check the install with `ohauthcat --version`.

### Verify the download

Every release on [GitHub](https://github.com/ohauthcat/cli/releases) ships `checksums.txt` with a SHA-256 line per file, and the installers refuse a file whose checksum does not match. To check a download yourself, compare `shasum -a 256 <file>` (or `Get-FileHash <file>` in PowerShell) with its line in `checksums.txt`. The checksum file is signed with cosign using a key pair, without the public transparency log (hence `--insecure-ignore-tlog=true`; the key is what you trust). Download the OhAuthCat public key from [ohauthcat.com/cli/cosign.pub](https://ohauthcat.com/cli/cosign.pub), save it as `cosign.pub`, and run:

```sh wrap
cosign verify-blob --key cosign.pub --signature checksums.txt.sig --insecure-ignore-tlog=true checksums.txt
```

### Uninstall

- **Install script:** delete the binary, `rm "$(command -v ohauthcat)"` (usually `/usr/local/bin/ohauthcat` or `~/.local/bin/ohauthcat`).
- **Homebrew:** `brew uninstall ohauthcat`.
- **Windows:** delete `%LOCALAPPDATA%\Programs\ohauthcat` and remove that folder from your user `Path` (Settings, then Edit environment variables for your account).
- **npm:** `npm uninstall -g @ohauthcat/cli`; `npx` keeps nothing to remove beyond its cache.

Run `ohauthcat logout` first if you want the saved credential revoked; uninstalling leaves keychain entries in place.

### Build from source

With authorized access to the `ohauthcat-cli` source and Go 1.26 (its `go.mod` pins the toolchain to go1.26.11), run `make build` in the checkout, which creates `bin/ohauthcat`.

`ohauthcat init` adds reviewed framework routes and registers your sandbox callback; see the [init quickstart](/get-started/quickstart-init/). The `dev`, `events`, `trigger`, `listen`, `migrate`, `import`, `export` and `scim test` commands are described in [CLI development and migration commands](/get-started/cli-commands/).

The [sandbox event relay API](/events/dev-relay/) is available independently of those CLI commands. Its HTTP and WebSocket contract supports live events, samples and optional redirect registration.

## Browser or device login

Run `ohauthcat login --profile work-sandbox`. The CLI opens the dashboard and receives a PKCE-protected callback on `127.0.0.1`. Approve only a request you initiated, check its client details, choose the intended environment and complete the dashboard's required recent second factor.

For a machine without a browser, run `ohauthcat login --device --profile work-sandbox`. Open the displayed verification URI on another device and enter the code. An unavailable browser also falls back to device authorization. Never send your device code to another person or approve an unexpected request. Requests expire; an old approval request returns [`cli_request_stale`](/errors/cli_request_stale/). Restart login rather than reusing it.

## Profiles and environment overrides

Run `ohauthcat whoami` to verify the environment ID and type. It reports credential source and an optional profile label; it does not verify your account, project or member identity. Run `ohauthcat env use work-sandbox` to select a saved profile. This selects local account/environment context, not a different backend environment on an existing credential.

| Configuration        | Behavior                                                                                                                                                                                                                                                                                                                                 |
| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `OHAUTHCAT_API_KEY`  | Takes precedence over saved credentials; never persisted or removed by commands. Suitable for your own CI secret injection.                                                                                                                                                                                                              |
| `OHAUTHCAT_PROFILE`  | Overrides the selected saved profile.                                                                                                                                                                                                                                                                                                    |
| `OHAUTHCAT_API_BASE` | Management API origin; defaults to `https://api.ohauthcat.com`. Must be an HTTPS origin without user information, path, query or fragment. Interactive login requires an `api.<domain>`, `dev-int-api.<domain>` or `stg-int-api.<domain>` origin; it opens the matching dashboard (`console.<domain>`, or `<env>-int-console.<domain>`). |

Credentials, profile metadata and the selected profile live in the OS keychain. Keychain failure stops the command; there is no plain-file fallback. `--json` emits device prompts and results without printing access or refresh tokens.

## Rotation, logout and revocation

Access and refresh tokens are saved as one keychain secret. Expiry or the specific invalid-access-token response triggers one serialized refresh. Refresh tokens are single use: core rotates both tokens, and replay of a spent refresh token revokes the credential family. There is no separate CLI `rotate` command.

The CLI retires the old token pair before sending a refresh request. A crash or ambiguous response requires a new login instead of retrying the spent token. Concurrent CLI processes serialize credential changes per profile.

Run `ohauthcat logout` to revoke the selected CLI credential remotely before removing its saved profile. A remote failure leaves the profile available for a retry. Saved API-key profiles are removed locally; `OHAUTHCAT_API_KEY` remains unchanged. Environment API keys are revoked in the dashboard (`ohauthcat keys revoke` prints the link); organization-scoped keys are revoked with `ohauthcat api-keys revoke <org> <key>`.

CLI credentials appear among your dashboard sessions with method `cli`. Revoking one from the dashboard's sessions list invalidates its entire token family. A CLI token cannot be used as a dashboard cookie. See [dashboard security](/get-started/dashboard-security/).
