-
Notifications
You must be signed in to change notification settings - Fork 9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Client id and client secret not added to request body on authorization #4192
Comments
Yes, it does seem like there's a branch of code missing for swagger-ui/src/core/plugins/auth/actions.js Lines 81 to 95 in 7fd229f
The Presumably it needs something like: if (clientId && clientSecret) {
switch (passwordType) {
case "query":
Object.assign(query, {client_id: clientId}, {client_secret: clientSecret})
break
case "request-body":
Object.assign(form, {client_id: clientId}, {client_secret: clientSecret})
break
default:
headers.Authorization = "Basic " + btoa(clientId + ":" + clientSecret)
}
} |
@scottohara I believe you're on the right track here. As always... PRs welcome, everyone 😉 |
I have the same issue. I'm using the same version as OP, but use the I can fill the fields How can I fix this? |
Hi did you figure out how to fix it? I get the same error |
I have one question. Is it possible to only use client_id and client_secret without username and password to authorize? |
getting the exact same issue as @schellingerht with a FastAPI implementation (python). client_id and client_secret not being added to request body but other params are - fastapi/fastapi#779 |
@schellingerht @monicatao @Charlie-iProov I have Swashbuckle.AspNetCore - version 6.2.3. And this bug is still not fixed. |
6.4.0 and year after bug is still here. :) |
I am also having problems caused by this issue. It looks like the code in Master is correct, but it isn't working. |
It looks like the fault is in oauth2-authorize.js. In the |
Yes, it sets |
I'm using Swagger UI from a .NET Core Web App, with an Azure AD app registration. My solution in the end was to inject a JavaScript file with fixes for the problems I found:
The JavaScript file contains this:
I don't think it is a great solution, but it has worked for my very specific use-case. I have looked at creating a PR for the Swagger UI code, but reading the various issues related to this problem, I am not sure I fully understand the intent of the code that is there and don't want to break existing functionality. I have also had to create a proxy controller (using AspNetCore.Proxy) to deal with a CORS issue (acting as a proxy for the token endpoint). |
When I click on "Authorize" in swagger-ui, fill in my username & password, client id & client secret, select "request body" for the method of including the client id & secret and then press "Authorize", the result is that the client id & secret are not added to the request body. As a result, my oauth endpoint gives an error that the client id is invalid.
I looked in the code a bit, and as far as I can see it checks if the method dropdown is set to "query" in which case it adds the client id & secret as query parameters and otherwise it always adds it as a header. Since "request body" is an option, it should check for that too and add it to the request body.
Demonstration
Expected Behavior
If I select "Request body" in the Authorize modal, then it should add the client id & secret to the request body.
Current Behavior
I select "request body" in the authorize modal, and instead it adds it to the header of the request, not the body.
Possible Solution
When the user selects "request body", add the client info to the request body, not the header of the request.
Context
Due to the current behaviour swagger-ui does not work with my project, since all my API calls require authentication which is now not possible with swagger-ui.
The text was updated successfully, but these errors were encountered: