Generate token into swagger api_key field in ASP Core 1.0

331 Views Asked by At

I added swagger to my Api Core, and I added a button "Authorize" with a field "api_key" where I put a jwt bearer token.

I'd like to generate the token when I arrive on the swagger page and validate the token to have a "Ready to use" swagger.

This is the code I used to create the "Authorize" button at the top :

 services.AddSwaggerGen(c =>
        {
            c.SwaggerDoc("v1", new Info { Title = "AcccountsAPI", Version = "v1" });
            c.AddSecurityDefinition("Bearer", new ApiKeyScheme() { In = "header", Description = "Please insert JWT with Bearer into field", Name = "Authorization", Type = "apiKey" });
        });

I'm using "Swashbuckle".

0

There are 0 best solutions below