Credentials
1 min read
The CLI needs an API token to communicate with the OpenCX API. Credentials can come from a local file or from environment variables.
Credentials File
After running opencx auth login, credentials are stored at:
~/.opencx/credentials
The file is JSON with two fields:
json
{
"token": "your-api-key",
"api_url": "https://api.open.cx"
}
File permissions are set to 0600 (owner read/write only) to protect the token from other users on the system.
Resolution Order
The CLI resolves credentials in the following order:
- Environment variables --
OPENCX_API_KEYandOPENCX_API_URL(see Environment Variables) - Credentials file --
~/.opencx/credentials
If environment variables are set, the credentials file is not read at all. This makes it safe to use both approaches on the same machine without conflict.
Re-authenticating
If your token expires or is revoked, run opencx auth login again. The CLI will overwrite the existing credentials file and reset permissions to 0600.