octo auth: sign in to the CLI
Sign in to the Askocto CLI with an API key, check which workspace you are using, sign out, and use OCTO_API_KEY in CI.
Working draft. These docs are illustrative: names, endpoints and examples describe the intended behaviour and can change before launch.
octo auth stores and checks the API key that every other command uses. Run it once on your machine, or skip it and set an environment variable in automated jobs.
Before you start
Create an API key in Workspace Settings > API keys. Keys start with oc_live_ for production or oc_test_ for testing, and the full key is shown once. A key acts on the whole workspace, so store it like a password. See Authentication for the rules that apply to keys.
Commands
| Command | What it does |
|---|---|
octo auth login |
Prompts for an API key and saves it to the config file. |
octo auth login --api-key KEY |
Saves the key without a prompt. |
octo auth status |
Shows the key prefix, the workspace and where the key came from. |
octo auth logout |
Removes the saved key. |
Sign in
Run the login command.
octo auth loginPaste your API key when asked. The input is hidden.
Run the status command to confirm.
octo auth status
You should see the workspace name, the key prefix such as oc_live_a1b2, and a line saying the key is stored in the config file. The key is written to ~/.config/octo/config.json. See Config.
Use the environment variable
In CI, set OCTO_API_KEY and run commands directly.
export OCTO_API_KEY="oc_test_your_key_here"
octo agents list --json
Which key wins
The CLI picks the first key it finds in this order:
- The
--api-keyflag on the command. - The
OCTO_API_KEYenvironment variable. - The key saved in the config file.
octo auth status tells you which source it used, which helps when a shell still has an old variable set.
Troubleshooting
unauthorizederror. The key is wrong, revoked or copied with a space. Create a new key and sign in again.- Wrong workspace. Keys belong to one workspace. Check
octo auth statusand sign in with the key from the right workspace. - Key shown in shell history. Avoid
--api-keyon shared machines. Use the prompt or the environment variable.
After signing in, run octo health to test the connection.