mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 10:58:17 -05:00
[PR #20138] [CLOSED] fix: resolve MCP OAuth 2.1 token refresh failure after access token expiration #64335
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/20138
Author: @imsamurai
Created: 12/23/2025
Status: ❌ Closed
Base:
dev← Head:dev📝 Commits (1)
ac7f87cFix mcp oauth token refresh📊 Changes
1 file changed (+4 additions, -4 deletions)
View changed files
📝
backend/open_webui/utils/oauth.py(+4 -4)📄 Description
Description
This pull request fixes an OAuth 2.1 token refresh issue for MCP integrations in Open WebUI.
When an MCP access token expires, Open WebUI fails to refresh it due to an incorrect client resolution inside the OpenID metadata lookup logic. This results in an exception during token refresh and prevents MCP usage in chat after token expiration.
The issue was caused by outdated logic in
get_server_metadata_url, which attempted to resolve OpenID configuration without using the proper client retrieval mechanism.This PR updates the implementation to consistently use
get_clientwhen resolving the OpenID metadata URL, ensuring the correct client configuration is used during token refresh.How to Reproduce
Observed Error
Root Cause
Before performing a token refresh, Open WebUI resolves the OpenID configuration URL to determine the refresh endpoint.
The function
get_server_metadata_urlused outdated logic and did not retrieve the OAuth client in the same way as the rest of the OAuth flow. This caused an invalid client configuration to be used, leading to a runtime exception during token refresh.Solution
get_server_metadata_urlto retrieve the OAuth client viaget_clientManual Testing
After applying the fix:
Result
Changelog Entry
Description
Fix OAuth 2.1 token refresh failure for MCP integrations caused by incorrect OpenID client resolution.
Fixed
Additional Information
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.