Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public void ConfigureServices(IServiceCollection services)
{
var thisServiceUrl = "https://myotherservice.myorg.com"; // Read from appsettings instead.
... // configure services for your application
// configure services for authentication
services
.AddAuthentication(options =>
{
option.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
option.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
})
.AddJwtBearer(options =>
{
options.Audience = thisServiceUrl;
options.Authority = Constants.Issuer;
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateAudience = true,
ValidateIssuer = true,
ValidateIssuerSigningKey = true,
ValidateLifetime = true,
};
});
return services;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment