Skip to main content

SSO & OAuth

OAuth and Single Sign-On (SSO) provide secure authentication for Open WebUI. When login problems occur, one of these common issues is usually the cause.

Common OAuth/SSO Issues​

1. WebUI URL Not Configured​

Most OAuth flows require the application's external URL ("redirect URI") so the provider knows where to send users after login. If this is missing, OAuth cannot complete.

Solution:

  • Navigate to: Settings > General (admin section)
  • Ensure your WebUI URL field is filled in and points to your deployed instance (e.g., https://yourwebui.yourdomain.com)
tip

Check for typos. OAuth is strict. URLs must match exactly, including https://.


2. Incorrect Environment Variable Configuration​

This is the most common cause of OAuth breakage. A misspelled, omitted, or incorrect environment variable will prevent authentication from working.

Common Environment Variable Mistakes:

Non-Existent Variables People Often Use:​

  • OIDC_CONFIG → Use OPENID_PROVIDER_URL instead
  • WEBUI_OIDC_CLIENT_ID → Use OAUTH_CLIENT_ID instead
  • WEBUI_ENABLE_SSO → OAuth is on by default through ENABLE_OAUTH. ENABLE_OAUTH_SIGNUP is only needed to let SSO create new accounts
  • WEBUI_AUTH_TYPE → This doesn't exist; configure provider-specific variables instead
  • OPENID_CLIENT_ID → Use OAUTH_CLIENT_ID instead
  • OPENID_CLIENT_SECRET → Use OAUTH_CLIENT_SECRET instead

Correct OIDC Variables:​


# Required for OIDC
OAUTH_CLIENT_ID=your_client_id
OAUTH_CLIENT_SECRET=your_client_secret
OPENID_PROVIDER_URL=https://your-provider/.well-known/openid-configuration

# Needed only for SSO to create accounts that do not exist yet
ENABLE_OAUTH_SIGNUP=true

# Optional but recommended
OAUTH_PROVIDER_NAME=Your Provider Name
OAUTH_SCOPES=openid email profile
OPENID_REDIRECT_URI=https://your-domain/oauth/oidc/callback

# Optional: pass provider-specific authorize params (JSON object)
# e.g. force consent screen, prefill user/email hint
OAUTH_AUTHORIZE_PARAMS={"prompt":"consent","login_hint":"[email protected]"}

Google-specific optional authorize params:​

# Optional: extra Google /authorize params as JSON
GOOGLE_OAUTH_AUTHORIZE_PARAMS={"prompt":"consent","login_hint":"[email protected]","hd":"example.com"}

Correct Microsoft Variables:​


# Use these for Microsoft Entra ID
MICROSOFT_CLIENT_ID=your_client_id
MICROSOFT_CLIENT_SECRET=your_client_secret
MICROSOFT_CLIENT_TENANT_ID=your_tenant_id
OPENID_PROVIDER_URL=https://login.microsoftonline.com/YOUR_TENANT_ID/v2.0/.well-known/openid-configuration
ENABLE_OAUTH_SIGNUP=true

Solutions:

  • Always reference the official environment configuration documentation for exact variable names
  • Double-check your deployment environment:
    • Ensure all required environment variables are set exactly as documented
    • If self-hosting, confirm these variables are present in your Docker Compose, Kubernetes manifest, or .env file
  • Restart your backend/app after changing variables so the new values are loaded
info

If your provider needs extra parameters at the /authorize step (for example prompt, login_hint, domain_hint, or resource), set them via OAUTH_AUTHORIZE_PARAMS as a JSON object.

For Google-specific customization, you can also use GOOGLE_OAUTH_AUTHORIZE_PARAMS.

tip

Most OAuth errors (loops, 401s, unresponsiveness) are due to an environment variable that is incorrectly named, missing entirely, or using an outdated variable name.

warning

Kubernetes/YAML users: Watch out for trailing spaces in environment variable names! In YAML, quoting a key like 'OAUTH_CLIENT_ID ' (with a trailing space inside the quotes) will set a variable named OAUTH_CLIENT_ID (with a space at the end), which Open WebUI will not recognize. Always ensure your env var names have no trailing whitespace:

# Wrong — trailing space inside quotes:
- name: 'OAUTH_CLIENT_ID '
  value: your_client_id

# Correct — no trailing space:
- name: OAUTH_CLIENT_ID
  value: your_client_id

3. Missing Required Variables​

OPENID_PROVIDER_URL is Mandatory for OIDC​

Many users forget this critical variable. Without it, OIDC authentication cannot work.

For Microsoft Entra ID:

OPENID_PROVIDER_URL=https://login.microsoftonline.com/YOUR_TENANT_ID/v2.0/.well-known/openid-configuration

For Google:

OPENID_PROVIDER_URL=https://accounts.google.com/.well-known/openid-configuration

For Authentik:

OPENID_PROVIDER_URL=https://your-authentik-domain/application/o/your-app-name/.well-known/openid-configuration

Other Required Variables by Provider:​

  • All OAuth providers: ENABLE_OAUTH (on by default), plus ENABLE_OAUTH_SIGNUP=true when SSO should create accounts. WEBUI_URL only matters behind a proxy that changes the request URL
  • Microsoft: MICROSOFT_CLIENT_ID, MICROSOFT_CLIENT_SECRET, MICROSOFT_CLIENT_TENANT_ID
  • Google: GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET
  • OIDC: OAUTH_CLIENT_ID, OAUTH_CLIENT_SECRET, OPENID_PROVIDER_URL

4. Persistent Configuration Conflicts​

Important: Open WebUI has two persistence settings that affect OAuth:

  1. ENABLE_PERSISTENT_CONFIG (defaults to true): Controls whether all settings (including OAuth) are loaded from the database rather than environment variables, once they've been saved to the DB.
  2. ENABLE_OAUTH_PERSISTENT_CONFIG (defaults to false): An additional gate specifically for OAuth settings. When set to false, OAuth settings with a config path starting with oauth. are not loaded from the database, even if ENABLE_PERSISTENT_CONFIG is true.

By default, OAuth env vars will take priority over database values because ENABLE_OAUTH_PERSISTENT_CONFIG defaults to false. However, if you previously configured OAuth through the Admin Panel, those DB values may have been saved, and they will be loaded if ENABLE_OAUTH_PERSISTENT_CONFIG is later set to true.

Symptoms:​

  • Changes to environment variables don't take effect after restart
  • Authentication worked once but broke after configuration changes
  • "No token found in localStorage" errors after reconfiguration

Solutions:

  1. For Development/Testing: Ensure ENABLE_OAUTH_PERSISTENT_CONFIG=false (this is already the default) to always read from environment variables
  2. For Production: Either:
    • Set ENABLE_OAUTH_PERSISTENT_CONFIG=true and configure settings through the Admin Panel instead of environment variables, OR
    • Keep ENABLE_OAUTH_PERSISTENT_CONFIG=false (default) so that env vars always take priority for OAuth settings
  3. Fresh Start: Delete the database volume and restart with correct configuration

While it is false the OAuth section of the Admin Panel is read-only, so an edit cannot look like it worked and then vanish on the next restart. See ENABLE_OAUTH_PERSISTENT_CONFIG.

Example for Docker Compose:

environment:
  - ENABLE_OAUTH_PERSISTENT_CONFIG=false  # Forces reading from env vars (this is the default)
  - OAUTH_CLIENT_ID=your_client_id
  - OAUTH_CLIENT_SECRET=your_secret
  - OPENID_PROVIDER_URL=your_provider_url

5. OAuth Misconfiguration on the Provider Side​

Sometimes the issue is with the identity provider (e.g., Google, Okta, Auth0, Azure AD) not aligning with your WebUI's setup.

Solutions:

  • Verify your application is correctly registered with the OAUTH provider. Confirm:
    • Redirect URIs exactly match your deployed WebUI address
      • OIDC: https://your-domain/oauth/oidc/callback
      • Microsoft: https://your-domain/oauth/microsoft/callback
      • Google: https://your-domain/oauth/google/callback
    • Client ID and secret match the values given in your environment settings
    • Scopes and allowed grant types (e.g., authorization_code) are set as required by Open WebUI
  • Check the provider's logs: misconfigured apps will often show clear error messages there

Redirect URI Format Examples:

Correct: https://ai.company.com/oauth/oidc/callback
Wrong: https://ai.company.com/oauth/callback/oidc
Wrong: https://ai.company.com/callback
tip

When in doubt, recheck your provider registration and regenerate client secrets if needed.


6. Server-Side Caching Issues​

If you use Nginx (or another reverse proxy) with server-side caching, OAuth endpoints can misbehave. This often manifests as random or intermittent login bugs that are difficult to debug.

Solutions:

  • In your NGINX (or proxy) configuration:
    • Make sure to exclude the following endpoints from server-side caching:
      • /api, /oauth, /callback, /login, /ws, /websocket
    • Any critical login/auth endpoint must remain uncached!
  • Reload the proxy config after making changes

Example NGINX Configuration:


# Disable caching for login / OAuth / websockets endpoints
location ~* ^/(api|oauth|callback|login|ws|websocket) {
    proxy_no_cache 1;
    proxy_cache_bypass 1;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_read_timeout 3600s;
    proxy_send_timeout 3600s;
    proxy_set_header Accept-Encoding "";
}
warning

Never cache OAuth or login endpoints. Caching can deliver stale tokens or corrupt sessions, causing unpredictable auth errors.


Common Problem: Reverse proxy cookie settings can interfere with OAuth authentication, especially the HttpOnly and SameSite settings.

Symptoms:​

  • "No token found in localStorage" errors
  • Redirect loops after successful authentication
  • Authentication works but immediately redirects to login page

Solutions:

For NGINX Proxy Manager:​


# Remove or adjust problematic cookie settings

# Problematic:

# proxy_cookie_path / "/; Secure; HttpOnly; SameSite=None";

# Better:
proxy_cookie_flags ~ secure samesite=lax;

# or remove cookie manipulation entirely

# Recommended cookie settings for OAuth
WEBUI_SESSION_COOKIE_SAME_SITE=lax
WEBUI_AUTH_COOKIE_SAME_SITE=lax
WEBUI_SESSION_COOKIE_SECURE=true  # Set to false if using HTTP
WEBUI_AUTH_COOKIE_SECURE=true     # Set to false if using HTTP

8. Network Timeout Issues​

OAuth providers may be slow to respond, causing timeout errors during the authentication handshake. Raise OAUTH_TIMEOUT to give them longer.

Symptoms:​

  • httpcore.ReadTimeout errors in logs
  • CSRF Warning! State not equal in request and response errors
  • OAuth login fails intermittently

Solutions:


# Increase the OAuth handshake timeout (seconds). AIOHTTP_CLIENT_TIMEOUT does not
# affect the OAuth client, which is httpx-based.
OAUTH_TIMEOUT=60

9. Session State Mismatch (CSRF Errors)​

Session cookies may not be properly maintained across the OAuth redirect flow.

Symptoms:​

  • CSRF Warning! State not equal in request and response
  • mismatching_state errors in logs
  • Authentication appears successful but redirects to login

Solutions:

  1. Check Cookie Domain Configuration:

# Ensure cookies are set for the correct domain
WEBUI_URL=https://your-exact-domain.com  # Must match exactly - check if you have a different value set in the admin panel
  1. Session Configuration:

# Ensure session handling is properly configured
WEBUI_SECRET_KEY=your_very_secure_random_key_here
OAUTH_SESSION_TOKEN_ENCRYPTION_KEY=another_secure_key_here

10. Load Balancer and Multi-Instance Issues​

In multi-instance deployments, OAuth sessions can fail if not properly synchronized.

Required Configuration for Clusters:​


# Redis for session synchronization (required for multi-instance)
REDIS_URL=redis://your-redis:6379/0
WEBSOCKET_REDIS_URL=redis://your-redis:6379/0

# Shared secrets across all instances
WEBUI_SECRET_KEY=same_on_all_instances
OAUTH_SESSION_TOKEN_ENCRYPTION_KEY=same_on_all_instances

# WebSocket support for clusters
ENABLE_WEBSOCKET_SUPPORT=true
WEBSOCKET_MANAGER=redis

11. Provider-Specific Configuration Issues​

Microsoft Entra ID Common Issues:​

Problem: Using generic OIDC variables instead of Microsoft-specific ones.

Correct Microsoft Setup:


# Use Microsoft-specific variables, not generic OIDC
MICROSOFT_CLIENT_ID=your_azure_app_id
MICROSOFT_CLIENT_SECRET=your_azure_app_secret
MICROSOFT_CLIENT_TENANT_ID=your_tenant_id
MICROSOFT_OAUTH_SCOPE=openid email profile
MICROSOFT_REDIRECT_URI=https://your-domain/oauth/microsoft/callback

# Needed only for SSO to create accounts that do not exist yet. OPENID_PROVIDER_URL is
# not required for Microsoft: login and sign-out use the tenant's own discovery URL.
ENABLE_OAUTH_SIGNUP=true

Problem: The sign-in fails at the callback with Sign-in with your identity provider failed. Please contact your administrator for assistance., and the log line that starts with OAuth callback error during authorize_access_token for provider microsoft contains AADSTS7000215. Microsoft's error code reference describes that code as "Invalid client secret is provided."

Solution: MICROSOFT_CLIENT_SECRET must hold the secret's Value, not the Secret ID listed next to it. In the Microsoft Entra admin center, open your app under App registrations, then Certificates & secrets > Client secrets. Microsoft shows the Value only once, when the secret is created, so if you no longer have it, create a new client secret and copy its Value. See Add and manage app credentials.

Authentik Common Issues:​

Problem: Incorrect provider URL format.

Correct Authentik Setup:

OAUTH_CLIENT_ID=your_authentik_client_id
OAUTH_CLIENT_SECRET=your_authentik_client_secret
OPENID_PROVIDER_URL=https://your-authentik-domain/application/o/your-app-slug/.well-known/openid-configuration
OAUTH_PROVIDER_NAME=Authentik
OAUTH_SCOPES=openid email profile

Providers that add their own parameters to the ID token:​

Problem: The login fails at the callback. The browser shows The email or password provided is incorrect, and the log records the real reason:

OAuth callback failed: Unsupported {'app_id'} in header

Some providers add a vendor-specific parameter to the ID token header, which older versions rejected. The name varies by provider.

Solution: Update Open WebUI. Unrecognized parameters are ignored, so nothing changes on the provider side. The signature and signing algorithm are still verified.

Providers that encrypt the ID token:​

Problem: The login fails at the callback with Sign-in with your identity provider failed. Please contact your administrator for assistance., and the log records:

OAuth callback failed: decode_error: Invalid JSON Web Signature

The ID token is not a signed token in the three-part form Open WebUI verifies. The usual cause is a provider set to encrypt the ID token (JWE). Open WebUI has no setting for a decryption key, so it cannot read an encrypted ID token.

Solution: At the provider, turn off ID token encryption for the Open WebUI client and keep the ID token signed.


12. Existing Accounts Cannot Sign In After a Long-Delayed Upgrade​

Problem: After upgrading an instance that had been left on a version older than v0.6.41, nobody who had signed in through SSO can get back in, and password sign-in fails for those same accounts. Accounts that never used SSO are fine. The log records:

ERROR - Error during OAuth process: 1 validation error for UserModel
oauth
Input should be a valid dictionary [type=dict_type, input_value='{"oidc": {"sub": "..."}}', input_type=str]

The upgrade step that moves an account's identity provider subject into its current field encoded the value twice, so it holds the text of a JSON object rather than the object. Only databases still older than v0.6.41 at the moment they were upgraded are affected, and only accounts that had a subject stored at the time.

Solution: Update Open WebUI. A repair migration runs on startup and rewrites the affected rows, leaving every other row alone. No manual database work, no re-linking and nothing to change on the provider side. OAUTH_MERGE_ACCOUNTS_BY_EMAIL does not work around it, since the fallback lookup reads the same account and fails the same way.


13. First SSO Sign-In Is Pending or Refused​

Problem: A person signs in through the provider for the first time. They either land on the Account Activation Pending screen, or they return to the sign-in page with this error:

You do not have permission to access this resource. Please contact your administrator for assistance.

The new account is pending​

A new SSO account gets the Default User Role from the User Access section of Settings > Authentication (admin section), set by DEFAULT_USER_ROLE. Its default is pending, so the account waits on the Account Activation Pending screen until an admin changes its role. With two-factor sign-in on, the sign-in page shows Your account is awaiting administrator approval. instead. The first account created on an empty instance becomes admin.

Solution: Use one of these:

  • Change the account's role to user under Admin Panel > Users.
  • Set Default User Role to user, so new accounts can use Open WebUI right away. This also applies to new accounts from the sign-up form and from LDAP.
  • Turn on Role Mapping (ENABLE_OAUTH_ROLE_MANAGEMENT), so the provider's roles decide between user and admin. See OAuth Role Management.

The sign-in is refused​

At the callback, Open WebUI looks for an account already linked to that provider and the person's sub. When none exists:

  • With OAUTH_MERGE_ACCOUNTS_BY_EMAIL on, an existing account with the same email is linked and signed in.
  • Otherwise, with ENABLE_OAUTH_SIGNUP off (the default), the sign-in is refused with the error above. This also happens when the person already has a local email and password account with the same email.
  • With ENABLE_OAUTH_SIGNUP on, a new account is created. If an account with that email already exists, the sign-in fails with Uh-oh! This email is already registered. Sign in with your existing account or choose another email to start anew.

The same error also appears when Role Mapping is on and the provider's roles match neither Allowed Roles nor Admin Roles. See OAUTH_ALLOWED_ROLES.

Solution:

  • To let SSO create accounts, set ENABLE_OAUTH_SIGNUP=true (OAuth Signup in the Admin Panel).
  • To let people who already have a local account sign in through SSO, set OAUTH_MERGE_ACCOUNTS_BY_EMAIL=true (Merge Accounts by Email). It links the sign-in to any account with that email, admin accounts included, and Open WebUI does not check whether the provider verified the address. Turn it on only for providers that verify email addresses.
  • While ENABLE_OAUTH_PERSISTENT_CONFIG is false (the default), these two toggles are read-only in the Admin Panel. Set the environment variables and restart.

The provider sends no roles claim​

With Role Mapping on, Open WebUI reads the claim named in Roles Claim (OAUTH_ROLES_CLAIM, default roles) from the ID token claims merged with the userinfo response. When the claim is missing, a new account gets the Default User Role and an existing account keeps its role.

Solution: If your provider sends the values you want to map under another claim, such as groups, set Roles Claim to that claim's name. Then list values from that claim in Allowed Roles and Admin Roles. The claim can be a list or a string, and a string is split on OAUTH_ROLES_SEPARATOR (default ,). A dotted name such as user.roles reads a nested claim.


Advanced Troubleshooting Tips​

Check Token Storage Method​

Recent versions of Open WebUI moved from URL-based tokens to cookie-based tokens. If you have authentication issues:

  1. Clear browser cookies and cache completely
  2. Check browser Developer Tools:
    • Look for oauth_session_id cookie (new method)
    • Check for any oauth_id_token cookie (legacy method)
    • Verify cookies have correct domain and path settings

Debugging OAuth Flow​

Enable debug logging and trace the OAuth flow:


# Enable detailed logging
GLOBAL_LOG_LEVEL=DEBUG

# Check logs for these key steps:

# 1. GET /oauth/{provider}/login - Should return 302 redirect

# 2. User authenticates with provider

# 3. GET /oauth/{provider}/callback?code=... - Should return 200 or redirect

# 4. User should be logged in

Database Debugging​

Check if user accounts are being created:


# Access your container
docker exec -it your-openwebui-container sh

# Check if users are created (adjust path to your data directory)
ls -la /app/backend/data/

Test Without Reverse Proxy​

If using a reverse proxy, test OAuth directly against Open WebUI:

  1. Temporarily expose Open WebUI port directly
  2. Update OAuth provider redirect URI to point to direct port
  3. Test authentication without proxy
  4. If it works, the issue is in your proxy configuration

Pro Tip: Check the Logs​

  • Look at backend logs and browser network errors. The first error usually points to the misconfiguration.
  • If unsure which side is the problem, try logging in from an incognito browser window and watch for blocked or failed requests.

Key Log Messages to Watch For:​

  • OAuth callback error: mismatching_state → Session/cookie issue
  • httpcore.ReadTimeout → Network timeout issue
  • Sign-in with your identity provider failed. Please contact your administrator for assistance. → The sign-in failed at the callback, for example because the provider denied access, the account has no email or its email domain is not allowed. The text is the same for all of these, so read the backend log for the actual cause. A role mismatch or a signup-disabled case shows the access-prohibited text, a duplicate email shows the already-registered error, and other exceptions show Error during OAuth process
  • Unsupported {'app_id'} in header → The provider adds a vendor-specific parameter to the ID token and your version still rejects it. See Providers that add their own parameters to the ID token
  • decode_error: Invalid JSON Web Signature → The ID token is not a signed token, usually because the provider encrypts it. See Providers that encrypt the ID token
  • Username claim is missing, using email as name → A new account was created with its email as its name, because the claim named in OAUTH_USERNAME_CLAIM was missing or empty
  • 1 validation error for UserModel on the oauth field → An old upgrade step stored the identity provider subject as text. See Existing Accounts Cannot Sign In After a Long-Delayed Upgrade
  • 404 on callback URLs → Redirect URI misconfiguration

Summary Checklist​

ProblemFix
WebUI URL missing or wrongSet correct WebUI URL in admin panel
Env var typo or missingDouble-check against official docs; avoid non-existent vars like OIDC_CONFIG
Missing OPENID_PROVIDER_URLAlways required for OIDC; set to provider's .well-known/openid-configuration
Persistent config conflictsSet ENABLE_OAUTH_PERSISTENT_CONFIG=false for env vars, or true to use the admin panel (it is read-only while false)
Provider misconfiguredConfirm app registration, URIs & client IDs/secrets
Proxy caching interferingExclude OAuth endpoints from all server-side caches
Cookie configuration issuesCheck reverse proxy cookie settings and env vars
Timeout problemsIncrease AIOHTTP_CLIENT_TIMEOUT values
CSRF/session issuesVerify WEBUI_SECRET_KEY and session configuration
Multi-instance problemsConfigure Redis and shared secrets
SSO accounts locked out right after a long-delayed upgradeUpdate Open WebUI; a repair migration fixes the stored identity data on startup
First SSO sign-in pending or refusedChange Default User Role, or set ENABLE_OAUTH_SIGNUP or OAUTH_MERGE_ACCOUNTS_BY_EMAIL. See First SSO Sign-In Is Pending or Refused
Still stuck?Check debug logs, test without proxy, verify provider setup

By carefully configuring both your OAuth provider and your Open WebUI environment, and keeping critical login endpoints immune from caching, you can eliminate nearly all SSO/OAuth login problems.


Signing Out of a Single Session Requires Redis

Without Redis, signing out does not revoke JWT tokens: they remain valid until they expire (default: 4 weeks). This is especially relevant for SSO/OAuth deployments where you may need to revoke access quickly (e.g., when an employee leaves the organization), because OIDC back-channel logout also needs Redis to revoke tokens. Without Redis, an administrator can still end every session of an account with Sign out all devices in the user's edit dialog.

For production SSO deployments, configure Redis or shorten JWT_EXPIRES_IN to limit exposure. See Token Revocation and the Redis tutorial for details.

This content is for informational purposes only and does not constitute a warranty, guarantee, or contractual commitment. Open WebUI is provided "as is." See your license for applicable terms.