Overview
Basic Memory Cloud supports two authentication methods:- OAuth 2.0 - Interactive browser-based authentication using WorkOS AuthKit
- API Keys - Long-lived tokens for CLI automation and cloud project routing
OAuth Authentication
OAuth is the primary authentication method for interactive CLI usage.Login Process
Authenticate using the device authorization flow:- Generates a device code
- Opens your browser for authentication
- Displays a user code for manual entry if needed
- Polls for authorization completion
- Stores tokens locally at
~/.basic-memory/.cloud_tokens.json - Verifies subscription access
Subscription Verification
If you don’t have an active subscription, you’ll see:Logout
Remove stored OAuth tokens:API keys (if configured) remain available after logout and continue to work for cloud project routing.
Check Authentication Status
Verify your authentication state and cloud connectivity:API Key Authentication
API keys provide long-lived authentication for:- CLI automation and scripts
- Per-project cloud routing
- Scenarios where OAuth is impractical
Creating API Keys
Method 1: Via CLI (requires OAuth first)
Create an API key through the cloud API:Method 2: Save Existing Key
If you already have an API key (e.g., from the web app):API keys must start with the
bmc_ prefix. Keys from other sources will be rejected.API Key Storage
API keys are stored in your Basic Memory configuration file at~/.basic-memory/config.yaml:
API Key Security
Authentication Priority
When both OAuth tokens and API keys are present, Basic Memory uses this priority:- API key - Used for per-project cloud routing when
project set-cloudis enabled - OAuth token - Used for global cloud operations and when API key is not configured
Per-Project Routing Example
Token Management
Token Storage Locations
- OAuth tokens:
~/.basic-memory/.cloud_tokens.json - API keys:
~/.basic-memory/config.yaml(undercloud_api_key)
Token Expiration
OAuth tokens expire after a period of inactivity. When a token expires:Token Refresh
OAuth tokens are automatically refreshed during the login process. You don’t need to manually refresh tokens.Troubleshooting
Browser Doesn’t Open
If the browser fails to open automatically:- Look for the authentication URL in the terminal
- Manually open the URL in your browser
- Enter the displayed user code
- Complete authentication
Authentication Timeout
The device authorization flow times out after 10 minutes. If you see a timeout error:Invalid API Key
If your API key is rejected:Subscription Issues
If subscription verification fails:- Verify your subscription is active at basicmemory.com/account
- If you just subscribed, wait a few minutes for propagation
- Try logging in again:
bm cloud login - Contact support if issues persist
Clearing Credentials
To completely reset cloud credentials:Environment Variables
Control authentication behavior with environment variables:| Variable | Default | Description |
|---|---|---|
BASIC_MEMORY_FORCE_LOCAL | false | Force local API routing (skip cloud) |
BASIC_MEMORY_FORCE_CLOUD | false | Force cloud API routing |
BASIC_MEMORY_EXPLICIT_ROUTING | false | Mark route selection as explicit |
Security Best Practices
OAuth
- Complete the authentication flow promptly (10-minute timeout)
- Close the browser tab after authentication
- Logout when using shared computers:
bm cloud logout
API Keys
- Use descriptive names to track key usage:
bm cloud api-key create "desktop-work" - Create separate keys for different machines/contexts
- Revoke unused keys through the web dashboard
- Never log or print API keys in scripts
Configuration Files
- Set restrictive permissions:
chmod 600 ~/.basic-memory/config.yaml - Don’t share configuration files containing API keys
- Add
~/.basic-memory/to.gitignorein projects
Next Steps
Bidirectional Sync
Set up file synchronization after authentication
Project Management
Configure cloud projects and routing
Cloud Setup
Complete cloud setup guide