You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
services.AddSwaggerGen(c =>
{
c.AddSecurityDefinition("Api Key in Header", new OpenApiSecurityScheme()
{
Name = "x-api-key",
In = ParameterLocation.Header,
Type = SecuritySchemeType.ApiKey,
Description = "Authorization by x-api-key inside request's header",
});
var key = new OpenApiSecurityScheme()
{
Reference = new OpenApiReference
{
Type = ReferenceType.SecurityScheme,
Id = "x-api-key"
},
In = ParameterLocation.Header,
Type = SecuritySchemeType.ApiKey
};
var requirement = new OpenApiSecurityRequirement
{
{ key, new List<string>() }
};
c.AddSecurityRequirement(requirement);
});
which result in the Authorize option pops up in UI:
However The API Key isn't sent from SwaggerUI to the Endpoint:
The header is missing
This is also the case if i inspect the Request.Headers object in the backend.
Am i missing something ?
The text was updated successfully, but these errors were encountered:
I've added the SecurityDefinition as well as SecurityRequirements as described here : https://stackoverflow.com/questions/57227912/swaggerui-not-adding-apikey-to-header-with-swashbuckle-5-x
which result in the Authorize option pops up in UI:
However The API Key isn't sent from SwaggerUI to the Endpoint:
The header is missing
This is also the case if i inspect the Request.Headers object in the backend.
Am i missing something ?
The text was updated successfully, but these errors were encountered: