mirror of
https://github.com/open-webui/open-webui.git
synced 2026-11-09 10:50:35 -06:00
[GH-ISSUE #16221] issue: Open WebUI: OIDC Token Exchange with Authentik Returns 405 Method Not Allowed #33357
Reference in New Issue
Block a user
Originally created by @icvdok on GitHub (Aug 2, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/16221
Check Existing Issues
Installation Method
Docker
Open WebUI Version
v0.6.18 (latest)
Ollama Version (if applicable)
ollama version is 0.10.1
Operating System
Windows 10
Browser (if applicable)
MS Edge - Firefox
Confirmation
README.md.Expected Behavior
Working OAUTH Integration, successful login Authentik users with OpenWebui
Actual Behavior
The auth process fail returning:{"detail":"The email or password provided is incorrect. Please check for typos and try logging in again."}.
Steps to Reproduce
Logs & Screenshots
From WebUI Docker:
2025-08-02 06:36:49.176 | INFO | uvicorn.protocols.http.httptools_impl:send:476 - 178.197.222.115:0 - "GET /api/config HTTP/1.1" 200 - {}
2025-08-02 06:36:49.287 | INFO | uvicorn.protocols.http.httptools_impl:send:476 - 178.197.222.115:0 - "GET /manifest.json HTTP/1.1" 200 - {}
2025-08-02 06:37:11.039 | INFO | uvicorn.protocols.http.httptools_impl:send:476 - 178.197.222.115:0 - "GET /oauth/oidc/login HTTP/1.1" 302 - {}
2025-08-02 06:37:13.149 | INFO | httpx._client:_send_single_request:1740 - HTTP Request: POST https://auth.mydomain.com/application/o/token/ "HTTP/1.1 405 Method Not Allowed" - {}
2025-08-02 06:37:13.150 | WARNING | open_webui.utils.oauth:handle_callback:352 - OAuth callback error: Expecting value: line 1 column 1 (char 0) - {}
2025-08-02 06:37:13.151 | INFO | uvicorn.protocols.http.httptools_impl:send:476 - 178.197.222.115:0 - "GET /oauth/oidc/callback?code=ead2b9e4883447099ff6ccd049fa2645&state=FI3NGKcSc9FRcsla162MB0Jir3DTmq HTTP/1.1" 400 - {}
Additional Information
environment: # https://docs.openwebui.com/getting-started/env-configuration#default_models
OLLAMA_BASE_URLS=http://host.docker.internal:11434 #comma separated ollama hosts
ENV=prod
WEBUI_AUTH=True
WEBUI_NAME=My AI App
WEBUI_URL=https://aibot.mydomain.com
WEBUI_SECRET_KEY=my-secret-key
ENABLE_OAUTH_SIGNUP=true
ENABLE_LOGIN_FORM=true
OAUTH_CLIENT_ID=my-oauth-client-id
OAUTH_CLIENT_SECRET=my-oauth-client-secret
OAUTH_PROVIDER_NAME=Authentik
OPENID_PROVIDER_URL=https://auth.mydomain.com/application/o/prd_webui/.well-known/openid-configuration
OAUTH_MERGE_ACCOUNTS_BY_EMAIL=true
OPENID_REDIRECT_URI=https://aibot.mydomain.com/oauth/oidc/callback
@dw-matt commented on GitHub (Aug 4, 2025):
Try adding
OAUTH_TOKEN_ENDPOINT_AUTH_METHOD=client_secret_post
It looks like the authentication library in Open WebUI uses "client_secret_basic" by default. This environment variable is not listed in the documentation but exists in the source code and tells the library to put the client secret in the post body instead of the request headers. All of the Authentik OAuth 2.0 examples use POST, so hopefully this helps.
@icvdok commented on GitHub (Aug 5, 2025):
Hello , thanks for the reply, unfortunately it return the same error:
{"detail":"The email or password provided is incorrect. Please check for typos and try logging in again."}
Here the log:
2025-08-05 04:27:49.852 | INFO | uvicorn.protocols.http.httptools_impl:send:476 - 178.197.202.121:0 - "GET /manifest.json HTTP/1.1" 200 - {} 2025-08-05 04:27:50.044 | INFO | uvicorn.protocols.http.httptools_impl:send:476 - 178.197.202.121:0 - "GET /api/config HTTP/1.1" 200 - {} 2025-08-05 04:27:52.233 | INFO | httpx._client:_send_single_request:1740 - HTTP Request: GET https://auth.mydomain.com.ch/application/o/prd_webui/.well-known/openid-configuration "HTTP/1.1 200 OK" - {} 2025-08-05 04:27:52.264 | INFO | uvicorn.protocols.http.httptools_impl:send:476 - 178.197.202.121:0 - "GET /oauth/oidc/login HTTP/1.1" 302 - {} 2025-08-05 04:27:54.244 | INFO | httpx._client:_send_single_request:1740 - HTTP Request: POST https://auth.mydomain.com/application/o/token/ "HTTP/1.1 405 Method Not Allowed" - {} 2025-08-05 04:27:54.245 | WARNING | open_webui.utils.oauth:handle_callback:352 - OAuth callback error: Expecting value: line 1 column 1 (char 0) - {} 2025-08-05 04:27:54.246 | INFO | uvicorn.protocols.http.httptools_impl:send:476 - 178.197.202.121:0 - "GET /oauth/oidc/callback?code=1cab95f304744ac984cbee77643b70c3&state=uoPWxX15lgn8r0CIKsJxYRkxOauOqk HTTP/1.1" 400 - {}@lwsrbrts commented on GitHub (Aug 6, 2025):
I'm using Authentik with my OWUI and it works as expected for me. The only difference I'm seeing is the lack of an environment variable for scopes. Mine is:
OAUTH_SCOPES: openid email profileOtherwise, the rest of my config looks like this, with some obvious stuff redacted.
@icvdok commented on GitHub (Aug 7, 2025):
Thanks, i'll try to add it.
@icvdok commented on GitHub (Aug 7, 2025):
No way, I've try almost everything. This is the last compose according to your feedbacks.
I'm quiet sure that the authentik process works but there is something in the webui that reject the token. Do you create the users in the webui with the same mail before login with the authentik users?
@lwsrbrts commented on GitHub (Aug 7, 2025):
I originally used OWUI with the built-in authentication and had created my account with my email address, which is the same email as I use for the Authentik system as well.
These two settings should mean that isn't necessary though:
I do however actually log on with my authentik username (not the email address), so when prompted at authentik's logon page, I just log on with
username.This is my entire docker compose for OWUI.
I'm sure you've seen this but authentik also document how to integrate OWUI with authentik here: https://integrations.goauthentik.io/miscellaneous/open-webui/
@kmamtora commented on GitHub (Aug 7, 2025):
I am getting Internal Server Error
@icvdok commented on GitHub (Aug 8, 2025):
Thanks @lwsrbrts , very helpful, I've try almost everything, any compose combinations and authentik options without success. Recreate the provider ,the application, recreate the dockers stack. I'try also to create an identical webui local usersame as the authentik user before swith to oauth, nothing. I've discovered that my self signed certificate was expired on authentik, created a new one but nothing change. Try to remove any cache in the frontend proxy, nothing. I'm stuck here now:
2025-08-08 07:04:17.076 | WARNING | open_webui.utils.oauth:handle_callback:352 - OAuth callback error: unsupported_algorithm: - {} 2025-08-08 07:04:17.077 | INFO | uvicorn.protocols.http.httptools_impl:send:476 - 178.197.210.130:0 - "GET /oauth/oidc/callback?code=a45ccfec78b94f05ae35da0d668a7d6a&state=ko0YvwVUjFokhhJcEYZhYpT3mHNvDl HTTP/1.1" 400 - {}Any change return always this error, the Authentik log is clean and confirm the authentication no errors are logged here. It's something on the webui server that create this issue (quiet common reading other posts) and there is no clear and documented solution as far as I know. I'll continue the investigation but this try and error approach is a very time consuming.
@icvdok commented on GitHub (Aug 8, 2025):
Finally I've get this things working. In case someone is interested, I had two main issues, CSRF state mismatch and an unsupported_algorithm error. In addition to the obvious checks like urls, client id, secrets matching on both side, here some other check that solve my situation.
1. mismatching_state: CSRF Warning!
This issue was caused by caching on my Nginx Proxy Manager (NPM) instance, which was interfering with the state parameter of the OAuth flow.
The Solution:
I disabled "Cache Assets" in the NPM Proxy Host settings for the Open WebUI domain.
I added a custom location for the /oauth/ path with explicit caching directives to ensure no caching occurs. The NPM "Advanced" tab for this location was set to:
This resolved the mismatching_state error in the logs.
2. unsupported_algorithm
This error occurred after the successful token exchange and was the result of a misconfiguration in Authentik's provider settings. Specifically, a signing key was being used for token encryption, which Open WebUI does not support.
The Solution:
I generated a new key pair in Authentik, ensuring the Private key Algorithm was set to RSA.
In the Authentik provider settings for Open WebUI, I set the new key for the Signing Key field.
Crucially, ensure the "Encryption Key" field is blank. Removing the key from this field prevented Authentik from encrypting the ID token, allowing Open WebUI to successfully validate the signature.
Minimal Working Docker Compose Configuration
Here is the minimal and working environment configuration for the Open WebUI Docker container:
General Notes and Observations
I'll continue to optimize the setup in the next future.
This investigation was challenging, and I hope this detailed report helps others who are facing similar struggles with Open WebUI and Authentik integration.
@Classic298 commented on GitHub (Aug 8, 2025):
Hey, it looks like your issues with caching and OAUTH provider config are covered in the official Open WebUI docs! Check out the 'Troubleshooting OAUTH / SSO Issues' section – especially points 3 and 4 about 'OAUTH Misconfiguration' and 'Server-Side Caching.' Hope it helps!