Token Types
| Token | Purpose | Lifetime | Storage |
|---|---|---|---|
| Access Token | API authorization | 1 hour (default) | Client-side (JWT) |
| Refresh Token | Obtain new access tokens | 30 days (default) | Server-side |
| Authorization Code | OAuth flow exchange | 60 seconds | Server-side, single-use |
| Session Token | Track user session | Configurable | Depends on mode |
Session Modes
FrontMCP supports two session management strategies:Stateful Sessions
Tokens stored server-side. Clients hold lightweight references.Pros:
- Silent token refresh
- Revocation without client update
- Secure token storage
- Requires shared storage (Redis)
- State management complexity
Stateless Sessions
All data embedded in JWT. No server-side storage.Pros:
- Horizontally scalable
- No shared state
- Simple architecture
- No silent refresh
- Larger token size
- Can’t revoke without expiry
Stateful Session Configuration
Stateless Session Configuration
Token Storage
In-Memory (Development)
In-memory storage loses all data on restart. Use only for development.
Redis (Production)
Storage Contents
| Key Pattern | Data | TTL |
|---|---|---|
{prefix}pending:{id} | Pending authorization | 10 minutes |
{prefix}code:{code} | Authorization code | 60 seconds |
{prefix}refresh:{token} | Refresh token | 30 days |
{prefix}session:{id} | Session data | Configurable |
OrchestratedTokenStore Interface
When using orchestrated mode with federated authentication, FrontMCP stores provider tokens using theOrchestratedTokenStore interface.
Interface Methods
| Method | Description |
|---|---|
storeTokens(authorizationId, providerId, tokens) | Store tokens for a provider |
getTokens(authorizationId, providerId) | Retrieve tokens for a provider |
deleteTokens(authorizationId, providerId) | Delete tokens for a provider |
getProviderIds(authorizationId) | Get all provider IDs with stored tokens |
migrateTokens(fromAuthId, toAuthId) | Migrate tokens between authorization IDs |
Token Migration
ThemigrateTokens() method is used internally during federated auth completion to transfer tokens from a pending authorization ID to the final authorization ID:
migrateTokens() is called automatically during the OAuth token exchange flow when completing federated authentication.Token Lifetimes
FrontMCP uses default token lifetimes:| Token Type | Default Lifetime |
|---|---|
| Access Token | 1 hour |
| Refresh Token | 30 days |
| Authorization Code | 60 seconds |
Token Refresh Configuration
Token lifetimes are currently set at the server level. Refresh tokens are rotated on each use per OAuth 2.1 best practices.
Token Refresh Flow
Refresh tokens are rotated on each use (OAuth 2.1 best practice):JWT Structure
Access tokens are JWTs with standard claims:Custom Claims
Add custom claims to tokens:Consent & Scopes
Enable consent to let users select granted permissions:How Consent Works
- User authenticates
- FrontMCP displays available tools/resources/prompts
- User selects which to grant
- Access token includes only selected scopes
Tool-Level Scopes
JWKS Management
FrontMCP manages cryptographic keys for token signing:Auto-Generated Keys
By default, keys are auto-generated at startup:Persistent Keys
Provide keys for stable token validation across restarts:Key Rotation
For production, implement key rotation:Token Verification
Verification Flow
Verification Options
Error Responses
Token-related errors follow OAuth 2.0 error format:| Error | HTTP Status | Description |
|---|---|---|
invalid_token | 401 | Token expired, malformed, or invalid signature |
insufficient_scope | 403 | Token missing required scopes |
invalid_request | 400 | Malformed token request |
invalid_grant | 400 | Invalid authorization code or refresh token |
Example Error Response
Next Steps
Authorization Modes
Choose the right auth mode for your use case
Progressive Authorization
Implement incremental app authorization
Production Checklist
Security requirements for deployment
Remote OAuth
Connect to external identity providers