mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 10:58:17 -05:00
[GH-ISSUE #18010] issue: MCP OAuth 2.1 flow doesn't match standard (missing code_challenge and resource_url) #18464
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?
Originally created by @hsuyuming on GitHub (Oct 2, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/18010
Check Existing Issues
Installation Method
Docker
Open WebUI Version
v0.6.32
Ollama Version (if applicable)
No response
Operating System
Debian 12
Browser (if applicable)
Chrome 140.0.7339.133
Confirmation
README.md.Expected Behavior
Authorization URL
Token URL
Actual Behavior
Authorization URL
The current implementation for generating authorization URLs is missing several required parameters, leading to security vulnerabilities and non-compliance with the MCP server's requirements.
The code_challenge and code_challenge_method parameters are not being included in the authorization URL. These are essential for implementing PKCE (RFC 7636), which protects against authorization code interception attacks. This is a critical security measure and a requirement from the MCP server.
The resource parameter is also missing from the URL's query string. According to the latest MCP specification, this parameter is mandatory.
https://modelcontextprotocol.io/specification/draft/basic/authorization#resource-parameter-implementation
token URL
The current implementation for generating token URLs is missing several required parameters (client_id, client_secret), after i included code_challenge_method when performing oauth.register (refer Additional Information)
Steps to Reproduce
Setup a secured MCP server
Setup open-webui
Logs & Screenshots
Error log within console
Additional Information
Suggestion change
1.include code_challenge_method when performing oauth.register. I'm not sure if there's a way to avoid hardcoding the value here. Normally we can get this data from mcp server metadata
2.Since we can obtain the client_id and client_secret, I recommend retrieving client_info before calling authorize_access_token. If client_id and client_secret are available, we should include them in the request, so these two parameters can be added accordingly.
After change
console log
Provide the reference on how the MCP inspector handles this.
@hsuyuming commented on GitHub (Oct 2, 2025):
@tjbck I would like to get your feedback to better understand your perspective on this.
@tjbck commented on GitHub (Oct 2, 2025):
@hsuyuming would be happy to review a PR!
@hsuyuming commented on GitHub (Oct 2, 2025):
sure, i can create a PR to kick off the discussion
@schveiguy commented on GitHub (Oct 4, 2025):
I ran into this same issue!
The two things I had to do to fix it were:
client_idandclient_secretwhen requesting the token (these were required by my MCP server, which is based on fastmcp2, at least the client_id seems mandatory per the RFC):With these changes, my oauth2 worked. I see your changes are similar, and got to roughly the same spot.
@schveiguy commented on GitHub (Oct 6, 2025):
@hsuyuming if you don't mind, I might pick up the PR submission, as I am kind of blocked without this fix.
@hsuyuming commented on GitHub (Oct 6, 2025):
@schveiguy I'm creating a PR for this.
@schveiguy commented on GitHub (Oct 6, 2025):
Great, thanks. I look forward to it getting fixed!
@hsuyuming commented on GitHub (Oct 6, 2025):
PR: https://github.com/open-webui/open-webui/pull/18087
@taylorwilsdon commented on GitHub (Oct 7, 2025):
Ran into the same today with a new fastmcp native oauth provider setup, thanks @hsuyuming!
@hsuyuming commented on GitHub (Oct 8, 2025):
Hi @tjbck :
I tested the v0.6.33 version from main branch and was able to complete the OAuth flow successfully. However, I noticed that the resource parameter is still missing from both the authorize and token endpoints, which is required by the MCP specification. Is there a plan to add this?
https://modelcontextprotocol.io/specification/draft/basic/authorization#resource-parameter-implementation
This is the the value of current authorize url within v0.6.33
@mjp0 commented on GitHub (Oct 11, 2025):
For me the issue with MCP oAuth flow is that once I've authorized, redirect url tries to go back to localhost:3000 instead of WEBUI_URL.
Am I missing some env that I need to set for the redirect url?
@taylorwilsdon commented on GitHub (Oct 12, 2025):
It's actually the base URL for Open WebUI in the general admin settings tab that dictates where the callback goes iirc
@schveiguy commented on GitHub (Oct 12, 2025):
@taylorwilsdon is right that the redirect url is dictated by the settings tab. But that is also set by setting
WEBUI_URL, so not sure what is happening on your end. Double check and make sure the setting is being taken.If that is correct, I suggest to open the dev tools of your browser, and watch the requests, see what the requested redirect url is. Things go by quickly, so you have to tick the box that keeps the dev tools open, and keeps the request history on refreshes. Watching what is sending what at which stage was very helpful to me.
In my case, my MCP server is authenticating against azure, so there are 2 callbacks. The first callback is to the MCP server, which stores the azure token, and then the second callback is to the OWUI server to store the MCP server token.
@mjp0 commented on GitHub (Oct 15, 2025):
I made a bit of progress on this but still no cigar.
Now the redirect URL is being set right but once it hits back to my server, I get oAuth error.
I get a request like
https://domain.com/oauth/clients/mcp:x7896yChLKO4RKcQTdkdDs04jIA_uPZup_Htc0uF043/callback?code=Hqr26iNlnxUlSicbvXAtPXsSDTdXLbyIrLg8AxFeI12&state=BPzf74et2PX3GS9nJtfPH6ZoN1lJ51which gets307 Temporary Redirecttohttps://domain.com/?error=OAuth%20callback%20error. The only error I see isOAuth callback errorwhich doesn't tell me anything, so I'm having a bit hard time debugging this.Any ideas?
@schveiguy commented on GitHub (Oct 15, 2025):
Check the log and network console. This is OWUI rejecting the callback for some reason.
@hsuyuming commented on GitHub (Oct 15, 2025):
Hi @tjbck:
Maybe you miss this question or should I ask this within discussion?
I tested the v0.6.33 version from main branch and was able to complete the OAuth flow successfully. However, I noticed that the resource parameter is still missing from both the authorize and token endpoints, which is required by the MCP specification. Is there a plan to add this?
https://modelcontextprotocol.io/specification/draft/basic/authorization#resource-parameter-implementation
This is the the value of current authorize url within v0.6.33
@tjbck commented on GitHub (Oct 15, 2025):
PR welcome here!