diff --git a/backend/open_webui/config.py b/backend/open_webui/config.py index 4070e03376..d0e693e319 100644 --- a/backend/open_webui/config.py +++ b/backend/open_webui/config.py @@ -620,6 +620,11 @@ OAUTH_UPDATE_PICTURE_ON_LOGIN = PersistentConfig( os.environ.get("OAUTH_UPDATE_PICTURE_ON_LOGIN", "False").lower() == "true", ) +OAUTH_ACCESS_TOKEN_REQUEST_INCLUDE_CLIENT_ID = ( + os.environ.get("OAUTH_ACCESS_TOKEN_REQUEST_INCLUDE_CLIENT_ID", "False").lower() + == "true" +) + def load_oauth_providers(): OAUTH_PROVIDERS.clear() diff --git a/backend/open_webui/utils/oauth.py b/backend/open_webui/utils/oauth.py index d3240b49a9..77a2ebd46e 100644 --- a/backend/open_webui/utils/oauth.py +++ b/backend/open_webui/utils/oauth.py @@ -53,6 +53,7 @@ from open_webui.config import ( OAUTH_ADMIN_ROLES, OAUTH_ALLOWED_DOMAINS, OAUTH_UPDATE_PICTURE_ON_LOGIN, + OAUTH_ACCESS_TOKEN_REQUEST_INCLUDE_CLIENT_ID, WEBHOOK_URL, JWT_EXPIRES_IN, AppConfig, @@ -1273,8 +1274,12 @@ class OAuthManager: client = self.get_client(provider) auth_params = {} + if client: - if hasattr(client, "client_id"): + if ( + hasattr(client, "client_id") + and OAUTH_ACCESS_TOKEN_REQUEST_INCLUDE_CLIENT_ID + ): auth_params["client_id"] = client.client_id try: