Unauthorized
The unauthorized error occurs when Command Code CLI is not properly authenticated or your credentials are invalid. This error signals that you need to authenticate before using Command Code.
- Not logged in to Command Code CLI.
- Invalid or expired authentication session.
- Authentication token has been revoked.
- A stale or revoked key in the
COMMAND_CODE_API_KEYenvironment variable. It overrides~/.commandcode/auth.json, socmd loginwon't fix it while it's set. - Running in CI or another non-interactive environment without
COMMAND_CODE_API_KEYset.
- Login to Command Code: Run
cmd logincommand to authenticate with Command Code CLI. - Verify authentication status: Check if you're properly logged in and your session is active.
- Re-authenticate: If your session has expired, log out and log back in to refresh your authentication.
- Check the env var: Run
cmd status. If it showsSource: $COMMAND_CODE_API_KEY, the env var is the active credential. Replace it with a valid key, or clear it to fall back to yourcmd loginsession:unset COMMAND_CODE_API_KEYon macOS / Linux,Remove-Item Env:COMMAND_CODE_API_KEYin Windows PowerShell. - In CI: Set
COMMAND_CODE_API_KEYfrom your CI provider's secrets store. See Headless authentication.
Ensure you are logged in to Command Code CLI with valid credentials. If you continue to experience issues, try logging out and logging back in.