Authentication Methods
Basic Memory supports two authentication methods:- JWT Tokens - OAuth2-based authentication for CLI and interactive use
- API Keys - Long-lived tokens for programmatic access
JWT Authentication (OAuth2)
Device Authorization Flow
The CLI uses OAuth2 Device Authorization with PKCE for secure authentication:- Generate a device code and PKCE challenge
- Open your browser to the authentication page
- Display a user code for verification
- Poll for token completion
- Save tokens securely to
~/.local/share/basic-memory/basic-memory-cloud.json
Token Storage
Tokens are stored in JSON format:0600 for security.
Using JWT Tokens
Include the JWT token in the Authorization header:Token Refresh
Access tokens expire after 1 hour. The CLI automatically refreshes tokens using the refresh token:API Key Authentication
Creating API Keys
API keys are ideal for server-to-server communication and automation:Setting API Keys
Save an API key for per-project cloud routing:Using API Keys
Include the API key as a Bearer token:API Key Format
API keys follow this format:- Prefix:
bmc_(Basic Memory Cloud) - Length: 32 characters (excluding prefix)
- Character set: alphanumeric (a-z, A-Z, 0-9)
bmc_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6
Per-Project Cloud Routing
You can route individual projects through the cloud while keeping others local:Authentication Errors
401 Unauthorized
Missing or invalid authentication:- Verify your token/API key is included in the Authorization header
- Check that the token hasn’t expired
- Ensure you’re using the correct authentication method
403 Forbidden
Valid authentication but insufficient permissions:- Verify your subscription is active
- Check that your API key has the required scopes
- Ensure you have access to the requested project
Security Best Practices
Rotate API Keys Regularly
Rotate API Keys Regularly
Create new API keys and revoke old ones every 90 days:
Use Environment Variables
Use Environment Variables
Store API keys in environment variables, not in code:
Limit API Key Scopes
Limit API Key Scopes
When creating API keys, limit their permissions to only what’s needed:
Monitor API Usage
Monitor API Usage
Regularly review API key usage:Revoke unused or suspicious keys immediately.
Local Development
When developing locally, authentication is disabled:Next Steps
Entities API
Create and manage knowledge entities
Search API
Search your knowledge graph