Skip to main content

Dual OAuth Configuration (Microsoft & Google)

Built-in providers

Google, Microsoft, GitHub and Feishu are separate built-in providers, each registered independently of the generic OIDC provider (OPENID_PROVIDER_URL). Only the generic OIDC slot is single, so Microsoft and Google can be enabled together without a workaround.

Overview​

Open WebUI registers Google, Microsoft, GitHub and Feishu as separate built-in providers alongside one generic OIDC provider, so Microsoft and Google can be enabled at the same time.

Prerequisites​

  • Access to your Open WebUI environment variables (Docker or local).
  • Client IDs and Secrets from both Google Cloud Console and Microsoft Azure/Entra ID.
  • OAUTH_MERGE_ACCOUNTS_BY_EMAIL=true must be enabled to ensure users are mapped to the same account regardless of the provider used.

Configuration logic​

Each built-in provider is registered from its own *_CLIENT_ID and *_CLIENT_SECRET (Microsoft also needs MICROSOFT_CLIENT_TENANT_ID). OPENID_PROVIDER_URL registers only the generic OIDC provider (together with OAUTH_CLIENT_ID and OAUTH_CLIENT_SECRET, or OAUTH_CODE_CHALLENGE_METHOD for PKCE); apart from that it is only a sign-out fallback for providers without their own discovery URL.

Environment Variables​

Add the following to your docker-compose.yaml or environment config:

# Enable signup and account merging (CRITICAL)
ENABLE_OAUTH_SIGNUP=true
OAUTH_MERGE_ACCOUNTS_BY_EMAIL=true

# 1. Microsoft (built-in provider)
# Registered as the built-in Microsoft provider from the first three variables
MICROSOFT_CLIENT_ID=your_microsoft_client_id
MICROSOFT_CLIENT_SECRET=your_microsoft_client_secret
MICROSOFT_CLIENT_TENANT_ID=your_tenant_id
MICROSOFT_REDIRECT_URI=https://your-webui.com/oauth/microsoft/callback
# Optional: not used to register Microsoft; a sign-out fallback that also silences the startup logout warning
OPENID_PROVIDER_URL=https://login.microsoftonline.com/your_tenant_id/v2.0/.well-known/openid-configuration

# Optional: Custom scope for Microsoft OAuth (required if using custom API scopes)
# MICROSOFT_OAUTH_SCOPE=openid email profile offline_access api://<Application ID URI>/<custom_scope>

# Optional: Include scope in refresh token requests (required for some Azure AD configurations)
# OAUTH_REFRESH_TOKEN_INCLUDE_SCOPE=true

# 2. Google as a secondary OAuth provider
# Note: Do NOT provide an OPENID_PROVIDER_URL for Google.
# The system will use its internal Google OAuth implementation.
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret

Why This Works​

  1. Microsoft is registered as the built-in Microsoft provider from MICROSOFT_CLIENT_ID, MICROSOFT_CLIENT_SECRET and MICROSOFT_CLIENT_TENANT_ID, with its own tenant discovery URL. OPENID_PROVIDER_URL registers nothing here, because the generic OIDC provider also needs OAUTH_CLIENT_ID.
  2. Google is registered as the built-in Google provider whenever GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET are set, regardless of any other provider.
  3. Account Merging: Since both providers return the user's email, OAUTH_MERGE_ACCOUNTS_BY_EMAIL=true ensures the user logs into the same profile whether they click "Sign in with Google" or "Sign in with Microsoft."

Troubleshooting​

  • Redirect Mismatch: Ensure the Redirect URIs in both consoles match MICROSOFT_REDIRECT_URI and GOOGLE_REDIRECT_URI if set, or otherwise the URL Open WebUI is reached at, since the callback URL is built from the incoming request; WEBUI_URL does not set the callback URL, only where the browser lands after sign-in.
  • Merge Failures: Double-check that OAUTH_MERGE_ACCOUNTS_BY_EMAIL is set to true.
  • Microsoft Logout: Sign-out discovers the end-session endpoint from the provider the session logged in with, so a Microsoft session logs out without OPENID_PROVIDER_URL; OPENID_END_SESSION_ENDPOINT overrides it if set.
  • Azure AD Refresh Token Failures (AADSTS90009): If token refresh fails with the error "Application is requesting a token for itself", set OAUTH_REFRESH_TOKEN_INCLUDE_SCOPE=true. Azure AD requires the scope to be explicitly included in refresh token requests. You may also need to set MICROSOFT_OAUTH_SCOPE to include offline_access and any custom API scopes.
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.