API keys for CLI automation
Use a scoped API key for CI, cron, containers, and other unattended CLI workloads. Keep human browser sessions separate from machine credentials.
Create a least-privilege key
Section titled “Create a least-privilege key”Create and manage keys directly from the CLI (this requires an interactive
browser session, so run champrep auth login first — API keys cannot manage
other API keys). The secret is printed once, so capture it immediately.
champrep keys create --name "nightly-export" --scope drive:readchamprep keys lsYou can also open API Keys in the dashboard.
Examples:
- A nightly Drive export normally needs
drive:read, not write or delete. - A calendar publisher can use
calendar:writewithout Mail or Work access. - A script that sends mail needs
mail:send; addmail:readonly if it also reads accounts, messages, or threads.
The active plan, profile, organization policy, role, and service-specific limits still apply after the scope check.
Store a key in the OS keychain
Section titled “Store a key in the OS keychain”champrep auth tokenThe command prompts securely and stores the key in the operating-system keychain. It does not write the token to the CLI configuration file.
Verify the result:
champrep auth whoamichamprep auth statusInject a key into CI
Section titled “Inject a key into CI”Store the key as a masked, protected CI secret named CHAMPREP_TOKEN. The CLI
uses that environment variable as an ephemeral override and bypasses the local
keychain.
champrep auth whoami --jsonchamprep drive quota --jsonDo not print the variable, enable shell command tracing around it, or pass it as a command-line argument. Restrict the secret to the branches and environments that need it.
Rotate without an outage
Section titled “Rotate without an outage”- Regenerate the secret (
champrep keys regenerate KEY_ID) or create a replacement key with the same necessary scopes (champrep keys create). - Update the secret manager or CI variable.
- Run a harmless identity or read command with the new key.
- Confirm the production workload has adopted it.
- Revoke the previous key (
champrep keys revoke KEY_ID).
Immediately revoke a key that may have been exposed. Treat a 401 from a
revoked key as terminal rather than retrying forever.
Review access
Section titled “Review access”List keys and inspect a key’s recent activity from the CLI:
champrep keys lschamprep keys get KEY_IDchamprep keys audit KEY_IDPeriodically check:
- whether the workload still exists;
- whether every selected scope is still required;
- whether IP restrictions can be narrowed;
- whether activity and last-used information match the workload;
- whether the key has a named owner and rotation schedule.
For the complete scope catalog and direct API use, see authentication and API keys.