Create auth middleware for single-user context (single active account per service)
Single-user mode:
Example:
const loopback = new LoopbackOAuthProvider({ service: 'outlook', ... });
const middleware = loopback.authMiddleware();
const tools = toolFactories.map(f => f()).map(middleware.withToolAuth);
const resources = resourceFactories.map(f => f()).map(middleware.withResourceAuth);
const prompts = promptFactories.map(f => f()).map(middleware.withPromptAuth);
Object with withToolAuth, withResourceAuth, withPromptAuth methods
Get access token from Keyv using compound key
OptionalaccountId: string
Account identifier (email address). Required for loopback OAuth.
Access token for API requests
Get user email from Microsoft Graph API (pure query) Used to query email for existing authenticated account
OptionalaccountId: string
Account identifier to get email for
User's email address
Handle OAuth callback from persistent endpoint. Used by HTTP servers with configured redirectUri.
OAuth callback parameters
Email and cached token
Convert to Microsoft Graph-compatible auth provider
OptionalaccountId: string
Account identifier for multi-account support (e.g., 'user@example.com')
Auth provider configured for the specified account
Loopback OAuth Client (RFC 8252 Section 7.3)
Implements OAuth 2.0 Authorization Code Flow with PKCE for native applications using loopback interface redirection. Manages ephemeral OAuth flows and token persistence with Keyv for key-based token storage using compound keys.
Token key format: {accountId}:{service}:token (e.g., "user@example.com:outlook:token")