# Credentials

The CLI reads your vault with a vault token from the Octet portal. Each token belongs to one licence and one environment, and that pair is the vault it reads. An auditor uses a delegation instead, and needs no token (see [Delegate to an Auditor](/docs/vaults/integration/delegate/)).

## Mint a token

1. Sign in to the [Octet portal](https://api.octetproof.com/portal/sign-in) as an owner or admin of the licence.
2. Open the licence's **Vaults** tab.
3. Pick the scope, the lifetime and the environment (**Release** or **Sandbox**), and mint the token.
4. Copy the token at once. The portal shows it only once.

| Scope | Lifetime | Allows |
|---|---|---|
| `vaults:read` | 7, 30 or 90 days. 30 by default. | Listing, reading, verifying, exporting and `monitor` |
| `vaults:admin` | 1 or 7 days. 1 by default. | Everything `vaults:read` allows, plus keys, the owner key, legal holds, deletion, delegations and grants |

A licence has at most 5 live vault tokens. You can revoke a token on the same tab, and it stops working within about a minute.

Mint a `vaults:admin` token only when you change something, and let it expire. Use a `vaults:read` token for everything that runs on a schedule.

## Give the token to the CLI

The CLI reads the token from the file you pass with `--token-file` or name in `OCTET_VAULT_TOKEN_FILE`, or from the `OCTET_VAULT_TOKEN` environment variable:

```bash
octet-vault --token-file read.token list
```

```bash
export OCTET_VAULT_TOKEN="$(cat read.token)"
octet-vault list
```

Keep token files readable by you only (`chmod 600`), and never commit them.

The CLI checks a token before it sends it. It refuses an empty token, a token that is not a `vaults:read` or `vaults:admin` token, and an expired one, names the file or variable the token came from, and sends nothing. It sends a token over `https://` only, or over `http://` to a loopback address, and follows no redirect.

## What a token can't do

- A vault token works only on the vault API. Your other Octet tokens, such as a proofs read token, get `401` on the vault API, and a vault token gets `401` on theirs.
- A `vaults:read` token gets `403 insufficient_scope` on anything that changes the vault.
- A token never opens a sealed object. Only your recipient key does.
