OAuth2 invalid redirection to localhost:3200 (SwaggerUi3)
See original GitHub issueWhen you switch from .UseSwaggerUi() to .UseSwaggerUi3() and try to use OAuth 2.0 Authorization in the Swagger Ui, the redirection after signing in (to e.g. Azure AD) always wants to go to localhost:3000.
So:
app.UseSwaggerUi(typeof(Startup).GetTypeInfo().Assembly, new SwaggerUiSettings()
{
OAuth2Client = new OAuth2ClientSettings
{
ClientId = clientId,
ClientSecret = clientSecret,
AppName = "App",
Realm = realm,
AdditionalQueryStringParameters =
{
{ "resource", clientId }
}
},
DocumentProcessors =
{
new SecurityDefinitionAppender("oauth2", new SwaggerSecurityScheme
{
Type = SwaggerSecuritySchemeType.OAuth2,
Description = "DocCheck",
Flow = SwaggerOAuth2Flow.Implicit,
AuthorizationUrl = authorizationUrl,
TokenUrl = tokenUrl,
})
},
OperationProcessors =
{
new OperationSecurityScopeProcessor("oauth2")
},
DefaultPropertyNameHandling = PropertyNameHandling.CamelCase,
});
works correctly.
If you change it to SwaggerUi3 and SwaggerUi3Settings without changing anything else, you always get redirected to localhost:3000 after signing in. I guess its hardcoded somewhere?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:29 (18 by maintainers)
Top Results From Across the Web
Swagger UI Authorization using IdentityServer4 returns ...
The redirect address with the port 3200 is hardcoded into the Swagger UI. Fortunately, there is a simple workaround by adding the key ......
Read more >Solved: Receiving a "redirect_uri_mismatch" error when aut...
I'm trying to use OAUTH 2.0 to authenticate/authorize. I'm testing on my local machine, where my application is running and accessible over HTTPS....
Read more >Authorization Code Request: 400 - Invalid redirect...
Hi, I'm in the process of implementing OAuth 2.0 server flow authentication on my platform which serves multiple organizations with each - 323044....
Read more >Not able to Authenticate through Swagger #1896
Apparently you have the dev environment redirect uri (https://localhost:44318/swagger/oauth2-redirect.html) and missing production redirect uri ...
Read more >OAuth2.0 Redirect URI invalid error - Help - Intuit
I'm trying to develop an app to connect to Bubble.io's API Connector, and using Bubble's generic redirect URI that's provided by their API ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I had the same issue using NSwag 11.18.6 on .NET Framework 4.6.1 web api.
The solution was set the Setting:
SwaggerUi3Settings.ServerUrl = "..."
@RSuter your fix from 19 Dec 2017 seems to work properly. Thanks!
I’ve created a new PR with a new setting: https://github.com/RSuter/NSwag/pull/1728 See #1717 (bottom) for more information