public static void ConfigureAuthentication(this IServiceCollection services, IConfiguration configuration) { // Configure the authentication service. services // Add support for authentication using JWT bearer based on the default // JWT authentication scheme. .AddAuthentication(JwtBearerDefaults.AuthenticationScheme) // Configure the JWT bearer authentication which is used for our API endpoints. .AddJwtBearer(options => { // Ensure only valid tokens are allowed if generated by our web application. options.SaveToken = true; // Configure the token validation parameters which should be used when our web application // received an authorization bearer token. options.TokenValidationParameters = JwtTokenHelper.CreateTokenValidationParameters(configuration); }); }