You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am currently using v5.22.0 release. I have two issues that setting Authorization header with OAuth2 doesn't work. Here is what I have done. with changes below, I can see Authorization button and can send token request and recevie a success response. However, the recevied token isn't attached to API request header like "Authorization: bearer xxxxxxxx". I have tried many things but nothing worked until now. can I get some help about this issue? it seems I need to add some code to add Authorization header in cs or js file but can't find what to do from documentation.
and second issue is if server responds with 200 OK status and Error message in response body, swagger ui thinks it was authenticated. I want to know how to validate the response as well.
Please let me know if need some more details. I will try to provide.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am currently using v5.22.0 release. I have two issues that setting Authorization header with OAuth2 doesn't work. Here is what I have done. with changes below, I can see Authorization button and can send token request and recevie a success response. However, the recevied token isn't attached to API request header like "Authorization: bearer xxxxxxxx". I have tried many things but nothing worked until now. can I get some help about this issue? it seems I need to add some code to add Authorization header in cs or js file but can't find what to do from documentation.
and second issue is if server responds with 200 OK status and Error message in response body, swagger ui thinks it was authenticated. I want to know how to validate the response as well.
Please let me know if need some more details. I will try to provide.
In swagger-initializer.js, I added initOAuth.
`
const ui = SwaggerUIBundle({
url: "/swagger/docs/v2",
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
// layout: "StandaloneLayout",
layout: "BaseLayout"
});
window.ui = ui;
ui.initOAuth({
// clientId: "",
// clientSecret: "", // optional, often not needed for implicit
// realm: "YOUR_REALM", // optional, often not needed for implicit
appName: "oauth2",
// scopeSeparator: " ",
// scopes: "",
useBasicAuthenticationWithAccessCodeGrant: false,
usePkceWithAuthorizationCodeGrant: false,
TokenUrl: "/v2/oauth2/token"
});
`
in the Swagger.config.cs file, I added
`
c.DocumentFilter();
c.OperationFilter();
`
and I have 2 classes for filter.
`
`
`
`
Beta Was this translation helpful? Give feedback.
All reactions