API Key Management
API keys are used to authenticate with the Codebuff backend and access model providers.Storage Location
Credentials are stored in your home directory:~/.config/manicode/credentials.json
Credentials File Format
The credentials file contains user authentication and OAuth tokens:credentials.json:
Authentication Flow
Reading User Credentials
Validating Credentials
Claude OAuth Credentials
For direct Anthropic API access, Codebuff manages Claude OAuth tokens.OAuth Token Schema
Getting OAuth Credentials
Saving OAuth Credentials
Token Refresh
Codebuff automatically refreshes expired OAuth tokens:Getting Valid Credentials
Always use this function to get credentials - it handles refresh automatically:Environment Variables
Credentials can also be provided via environment variables:Claude OAuth Token
Security Best Practices
File Permissions
Ensure credentials file has restrictive permissions:Never Commit Credentials
Add to.gitignore:
Environment-Specific Credentials
Codebuff supports environment-specific config directories:- Production:
~/.config/manicode/ - Development:
~/.config/manicode-dev/ - Staging:
~/.config/manicode-staging/
Token Expiry Handling
Always check token validity before use:Clearing Credentials
Next Steps
- Learn about Model Providers
- Explore Error Handling
- See File System Access

