diff --git a/backend/open_webui/utils/oauth.py b/backend/open_webui/utils/oauth.py index 0b4a1d55e0..ddf9af6294 100644 --- a/backend/open_webui/utils/oauth.py +++ b/backend/open_webui/utils/oauth.py @@ -266,11 +266,11 @@ async def get_authorization_server_discovery_urls(server_url: str) -> list[str]: ) as response: if response.status == 401: match = re.search( - r'resource_metadata="([^"]+)"', + r'resource_metadata=(?:"([^"]+)"|([^\s,]+))', response.headers.get('WWW-Authenticate', ''), ) if match: - resource_metadata_url = match.group(1) + resource_metadata_url = match.group(1) or match.group(2) log.debug(f'Found resource_metadata URL: {resource_metadata_url}') # Step 2: Fetch Protected Resource metadata