Authentication
Gumnut supports multiple authentication methods to suit different use cases, from simple API keys for server-side applications to OAuth for user-facing integrations.Authentication Methods
API Keys
API keys are the simplest way to authenticate with Gumnut. They’re ideal for:- Server-side applications
- Scripts and automation
- Development and testing
- CI/CD pipelines
Creating an API Key
- Log into the Gumnut Dashboard
- Navigate to API Keys
- Click Create API Key
- Name your key descriptively (e.g., “Production Server”, “Development”)
- Copy and securely store the key
API keys are shown only once when created. Store them securely in environment variables or a secrets manager. Never commit API keys to version control.
Using API Keys
Include your API key in theAuthorization
header of your requests:
OAuth 2.1
Gumnut implements OAuth 2.1 through Clerk for secure, user-facing authentication. OAuth is ideal for:- Web applications
- Mobile apps
- Third-party integrations
- Applications requiring user consent
How OAuth Works
OAuth allows third-party applications to access Gumnut resources on behalf of a user without exposing their credentials:- Authorization Request: Your app redirects users to Gumnut’s authorization page
- User Consent: Users approve the requested permissions (scopes)
- Authorization Code: Gumnut redirects back with an authorization code
- Token Exchange: Your app exchanges the code for access tokens
- API Access: Use the access token to make authorized requests
OAuth Endpoints
Gumnut provides standard OAuth 2.1 endpoints:- Authorization:
https://api.gumnut.ai/oauth/authorize
- Token:
https://api.gumnut.ai/oauth/token
- Token Revocation:
https://api.gumnut.ai/oauth/revoke
OAuth Metadata
OAuth metadata is available at these well-known endpoints:- Protected Resource:
/.well-known/oauth-protected-resource/mcp
- Authorization Server:
/.well-known/oauth-authorization-server
Supported OAuth Flows
Authorization Code Flow with PKCE (Recommended):OAuth Scopes
Control access with granular scopes:read:assets
- View photos and videoswrite:assets
- Upload and modify assetsread:albums
- View albumswrite:albums
- Create and modify albumsread:people
- View people and faceswrite:people
- Modify people dataread:libraries
- View librarieswrite:libraries
- Modify libraries
Using OAuth Tokens
Once obtained, use OAuth tokens like API keys:Session Tokens (Web Applications)
For web applications using Clerk, session tokens are automatically managed through cookies:Security Best Practices
API Key Security
- Environment Variables: Always store keys in environment variables
- Rotation: Rotate keys periodically
- Minimal Scope: Create separate keys for different environments
- Monitoring: Track key usage in the dashboard
- Revocation: Immediately revoke compromised keys
OAuth Security
- PKCE: Always use PKCE for public clients
- State Parameter: Include state to prevent CSRF attacks
- Secure Storage: Store tokens securely (never in localStorage for sensitive data)
- Token Refresh: Implement token refresh for long-lived sessions
- Scope Limitation: Request only necessary scopes
HTTPS Only
All API requests must use HTTPS. HTTP requests will be rejected.Rate Limiting
Authentication doesn’t bypass rate limits. See our API documentation in the API reference tab for current limits.Error Handling
Common Authentication Errors
401 Unauthorized:retry_after
header
WWW-Authenticate Headers
Failed authentication returns proper WWW-Authenticate headers:Token Management
API Key Management
View and manage API keys in the dashboard:- See creation date and last used time
- Track usage statistics
- Revoke keys instantly
- Set expiration dates (coming soon)
OAuth Token Lifecycle
- Access Token: Short-lived (1 hour default)
- Refresh Token: Long-lived (30 days)
- Token Refresh: Exchange refresh token for new access token
- Revocation: Explicitly revoke tokens when needed
Integration Examples
Node.js with API Key
Python with OAuth
React with Clerk
Troubleshooting
Invalid API Key
- Verify the key is copied correctly
- Check it hasn’t been revoked in the dashboard
- Ensure you’re using the correct environment’s key
OAuth Redirect Issues
- Verify redirect URI matches exactly (including trailing slashes)
- Ensure redirect URI is whitelisted in your OAuth app settings
- Check for URL encoding issues
Token Expiration
- Implement token refresh logic for OAuth
- Monitor token expiry times
- Handle 401 responses gracefully with retry logic
CORS Issues (Browser)
- OAuth tokens work in browsers with proper CORS headers
- API keys should not be used in client-side code
- Use a backend proxy for API key authentication
Next Steps
- Explore the API Reference tab for all endpoints
- Learn about Webhooks for real-time updates
- Set up the MCP Server for AI tool integration
- Review our SDKs for easier integration