diff --git a/backend/open_webui/config.py b/backend/open_webui/config.py index 8fac490c1..1ce646c6c 100644 --- a/backend/open_webui/config.py +++ b/backend/open_webui/config.py @@ -687,7 +687,6 @@ def load_oauth_providers(): return client OAUTH_PROVIDERS['google'] = { - 'redirect_uri': GOOGLE_REDIRECT_URI.value, 'register': google_oauth_register, } @@ -708,7 +707,6 @@ def load_oauth_providers(): return client OAUTH_PROVIDERS['microsoft'] = { - 'redirect_uri': MICROSOFT_REDIRECT_URI.value, 'picture_url': MICROSOFT_CLIENT_PICTURE_URL.value, 'register': microsoft_oauth_register, } @@ -733,7 +731,6 @@ def load_oauth_providers(): return client OAUTH_PROVIDERS['github'] = { - 'redirect_uri': GITHUB_CLIENT_REDIRECT_URI.value, 'register': github_oauth_register, 'sub_claim': 'id', } @@ -775,7 +772,6 @@ def load_oauth_providers(): OAUTH_PROVIDERS['oidc'] = { 'name': OAUTH_PROVIDER_NAME.value, - 'redirect_uri': OPENID_REDIRECT_URI.value, 'register': oidc_oauth_register, } diff --git a/backend/open_webui/utils/oauth.py b/backend/open_webui/utils/oauth.py index ab1213857..0cbe753b7 100644 --- a/backend/open_webui/utils/oauth.py +++ b/backend/open_webui/utils/oauth.py @@ -1354,12 +1354,13 @@ class OAuthManager: if provider not in OAUTH_PROVIDERS: raise HTTPException(404) # If the provider has a custom redirect URL, use that, otherwise automatically generate one - redirect_uri = OAUTH_PROVIDERS[provider].get('redirect_uri') or request.url_for( - 'oauth_login_callback', provider=provider - ) client = self.get_client(provider) if client is None: raise HTTPException(404) + redirect_uri = ( + (client.server_metadata or {}).get('redirect_uri') + or request.url_for('oauth_login_callback', provider=provider) + ) kwargs = {} if auth_manager_config.OAUTH_AUDIENCE: