Using Swashbuckle.AspNetCore, I got a Swagger interface for my .NET core REST API, with an "Authorize" button that takes me to my Single Sign-On server:
I need to do the same in an ASP.NET application based on .NET Framework 4.8, using the Swashbuckle package, but I don't get the Authorize button:
This is my initialization code:
using System.Web.Http;
using WebActivatorEx;
using Swashbuckle.Application;
[assembly: PreApplicationStartMethod(typeof(SwaggerConfig), "Register")]
namespace Test {
public class SwaggerConfig {
public static void Register() {
var thisAssembly = typeof(SwaggerConfig).Assembly;
GlobalConfiguration.Configuration
.EnableSwagger(c => {
c.SingleApiVersion("v1", "Rest Test");
c.OAuth2("oauth2")
.Description("OAuth2 Implicit Grant")
.Flow("implicit")
.AuthorizationUrl("https://keycloak.some.test/auth/realms/test/protocol/openid-connect/auth")
.TokenUrl("https://keycloak.some.test/auth/realms/test/protocol/openid-connect");
c.DescribeAllEnumsAsStrings();
})
.EnableSwaggerUi(c => {
c.EnableOAuth2Support(
clientId: "test-client",
clientSecret: null,
realm: "test",
appName: "Swagger UI"
);
});
}
}
}
Is there a way to get the authorize button with Swashbuckle on ASP.NET, using the .NET framework and not .NET core? Am I missing some initialization?
I tried searching for this issue, but all the answers and documentation I've found were related to .NET core, and for me it's essential to use .NET framework 4.8.


