first you need an anonymous endpoint that allows login and returns a valid token:
https://learn.microsoft.com/en-us/azure/active-directory-b2c/access-tokens
you can skip this if you already have a way to get the access token value
then add token support to swagger
builder.Services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "Test01", Version = "v1" });
c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme()
{
Name = "Authorization",
Type = SecuritySchemeType.ApiKey,
Scheme = "Bearer",
BearerFormat = "JWT",
In = ParameterLocation.Header,
Description = "JWT Authorization header value: Bearer {token}"
});
c.AddSecurityRequirement(new OpenApiSecurityRequirement
{
{
new OpenApiSecurityScheme
{
Reference = new OpenApiReference
{
Type = ReferenceType.SecurityScheme,
Id = "Bearer"
}
},
new string[] {}
}
});
});
in the swagger ui via authorize, you can enter the token header value ("Bearer {token}") using the token the login action returns