From 3d7f766d3891fa0b73c41a032e371b7d05678167 Mon Sep 17 00:00:00 2001 From: "mintlify[bot]" <109931778+mintlify[bot]@users.noreply.github.com> Date: Tue, 7 Apr 2026 16:55:52 +0000 Subject: [PATCH] Document CLI auto-refresh tokens, keychain storage, and MINTLIFY_SESSION_TOKEN env var Generated-By: mintlify-agent --- cli/commands.mdx | 14 +++++++++++++- cli/preview.mdx | 13 ++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/cli/commands.mdx b/cli/commands.mdx index 802d00d39..95bf865d6 100644 --- a/cli/commands.mdx +++ b/cli/commands.mdx @@ -40,7 +40,9 @@ Authenticate with your Mintlify account. mint login ``` -Opens a browser window to complete authentication. If the browser does not open, the CLI displays a URL to open manually and a prompt to paste the authorization code. Credentials save in `~/.config/mintlify/config.json`. +Opens a browser window to complete authentication. If the browser does not open, the CLI displays a URL to open manually and a prompt to paste the authorization code. Credentials are stored securely in your operating system's keychain. When your access token expires, the CLI automatically refreshes it without requiring you to log in again. + +You can also authenticate using the `MINTLIFY_SESSION_TOKEN` environment variable for CI/CD or headless environments. See [Preview locally](/cli/preview#authenticate-with-an-environment-variable) for details. --- @@ -348,3 +350,13 @@ You can also disable telemetry by setting one of these environment variables: | `DO_NOT_TRACK` | `1` | Disable telemetry using the [Console Do Not Track](https://consoledonottrack.com/) standard. | Your preference saves in `~/.config/mintlify/config.json` and persists across CLI sessions. + +--- + +## Environment variables + +| Variable | Description | +| --- | --- | +| `MINTLIFY_SESSION_TOKEN` | Authenticate the CLI without browser login. Useful for CI/CD pipelines and headless environments. The CLI uses keychain credentials first and falls back to this variable. | +| `MINTLIFY_TELEMETRY_DISABLED` | Set to `1` to disable anonymous telemetry. | +| `DO_NOT_TRACK` | Set to `1` to disable telemetry using the [Console Do Not Track](https://consoledonottrack.com/) standard. | diff --git a/cli/preview.mdx b/cli/preview.mdx index 51693875e..c473213b5 100644 --- a/cli/preview.mdx +++ b/cli/preview.mdx @@ -34,7 +34,7 @@ You must authenticate the CLI with your Mintlify account to enable search and th mint login ``` -After you authenticate with the `mint login` command, the CLI stores your credentials in `~/.config/mintlify/config.json` so you stay logged in across sessions. +After you authenticate with the `mint login` command, the CLI stores your credentials securely in your operating system's keychain so you stay logged in across sessions. When your access token expires, the CLI automatically refreshes it in the background without requiring you to log in again. Once logged in, run `mint dev` to start the local preview with search and the assistant enabled. The assistant uses the same indexed content as your deployed documentation site. @@ -50,6 +50,17 @@ To log out, run: mint logout ``` +### Authenticate with an environment variable + +For CI/CD pipelines or headless environments where browser-based login is not available, set the `MINTLIFY_SESSION_TOKEN` environment variable: + +```bash +export MINTLIFY_SESSION_TOKEN=your-token +mint dev +``` + +The CLI uses the keychain token first and falls back to `MINTLIFY_SESSION_TOKEN` if no keychain credentials are available or if the token cannot be refreshed. + ## Custom ports By default, the CLI uses port 3000. To use a different port, use the `--port` flag: