Generate Keys
To generate a new API or APP key pair, use thekeys generate command:
Options
--key-type: Specify the type of key to generate (API or APP). Default is API.--alg: Specify the key generation algorithm. Default is ed25519.--force: Force replacement of existing keys.
Examples
Generate a new API key pair:Key Storage
Generated keys are securely stored in your environment file (default: ~/.cobo/.env). The public key is stored as<ENV>_<KEY_TYPE>_KEY, and the secret key is stored as <ENV>_<KEY_TYPE>_SECRET.
Using API Keys for Authentication
After generating an API key pair, follow these steps to use it for authentication with the Cobo CLI:- Switch to API key authentication using the following command:
- Add the newly generated API key to the Cobo Portal:
- Log in to the Cobo Portal and navigate to the developer console.
- Find the API Key Management page.
- Add the newly generated API key (use the public key).
- Grant the API key appropriate wallet scope, roles, and permissions.
- Once you’ve added the API key to the Cobo Portal and set the appropriate permissions, your Cobo CLI will be able to authenticate using this key for subsequent operations.
Remember to update the API key in the Cobo Portal’s API Key management console every time you generate a new key pair using the CLI.
Best Practices
- Regularly rotate your API and APP keys to maintain security.
- Use different keys for different environments (development, sandbox, production).
- Limit the permissions associated with each key to the minimum required for its intended use.
- Monitor key usage and revoke any keys that may have been compromised.
