Auth0 can be used as an OpenID Connect provider for LibreChat. When using Auth0 with token reuse enabled (OPENID_REUSE_TOKENS=true), you must configure the OPENID_AUDIENCE environment variable to prevent authentication issues.
Auth0 does not allow http://localhost URLs in production applications. For local development/testing, you'll need to use HTTPS. You can use services like:
ngrok: ngrok http 3080 (provides HTTPS tunnel to localhost)
Caddy: Local HTTPS proxy server
localtunnel: Similar to ngrok
Example with ngrok:
ngrok http 3080# This will give you a URL like: https://abc123.ngrok.io
This step is required when using OPENID_REUSE_TOKENS=true. Without it, Auth0 will return opaque tokens that cannot be validated by LibreChat, causing infinite refresh loops.
Go to Auth0 Dashboard → Applications → APIs
Click "Create API"
Configure the API:
Name: LibreChat API (or your preferred name)
Identifier: https://api.librechat.ai (or your preferred identifier)
Note: This is just a unique identifier, not an actual URL. It doesn't need to be accessible.
Common patterns: https://api.yourdomain.com, https://librechat.yourdomain.com, etc.
Add the following environment variables to your .env file:
# OpenID Connect Configuration# Domain from Basic Information (add https:// prefix)OPENID_ISSUER=https://dev-abc123.us.auth0.com# Client ID from Basic InformationOPENID_CLIENT_ID=your_long_alphanumeric_client_id# Client Secret from Basic Information (click to reveal)OPENID_CLIENT_SECRET=your_client_secret_from_basic_information# Callback URL (must match what's configured in Auth0)OPENID_CALLBACK_URL=/oauth/openid/callback# Token ConfigurationOPENID_REUSE_TOKENS=trueOPENID_SCOPE=openid profile email offline_access# IMPORTANT: Your Auth0 API identifier (from Step 3)OPENID_AUDIENCE=https://api.librechat.ai# Security Settings (recommended)OPENID_USE_PKCE=true# Session Configuration (generate a secure random string)OPENID_SESSION_SECRET=your-secure-session-secret-32-chars-or-more# Optional: Custom button appearanceOPENID_BUTTON_LABEL=Continue with Auth0# OPENID_IMAGE_URL=https://path-to-auth0-logo.png# If using ngrok for testing, also update:# DOMAIN_CLIENT=https://your-domain.ngrok.io# DOMAIN_SERVER=https://your-domain.ngrok.io