Swashbuckle.aspnetcore: How do you add Basic Authentication to your swagger documentation page?

Created on 16 Nov 2017  路  4Comments  路  Source: domaindrivendev/Swashbuckle.AspNetCore

version using: 1.1.0

With Swashbuckle, how do you add basic authentication to your swagger documentation page?
How do you update the ui to accept username and password? (like attached pic)

swagger-basicauth

Most helpful comment

Hi
I have a little authorization tool for Swashbuckle and Bearer token.
https://github.com/janmohammadi/swashbuckle-authorize

How it works

All 4 comments

I believe you follow the steps listed in the docs here:
https://github.com/domaindrivendev/Swashbuckle.AspNetCore#swashbuckleaspnetcoreswaggergen but instead of using the OAuth2Scheme class, you would use the BasicAuthScheme class

Thanks @wdspider!
For my particular needs I went with ApiKeyScheme:
services.AddSwaggerGen(c =>
{
...
c.AddSecurityDefinition("Bearer", new ApiKeyScheme() { In = "header", Description = "Please insert JWT with Bearer into field", Name = "Authorization", Type = "apiKey" });
});

image

image

Hi
I have a little authorization tool for Swashbuckle and Bearer token.
https://github.com/janmohammadi/swashbuckle-authorize

How it works

Thank you very much!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rgelb picture rgelb  路  3Comments

voroninp picture voroninp  路  3Comments

m-demydiuk picture m-demydiuk  路  3Comments

jluqueba picture jluqueba  路  4Comments

vanillajonathan picture vanillajonathan  路  3Comments