public static IServiceCollection AddJwtBearer(this IServiceCollection services) { AuthenticationBuilder builder = services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme); IConfigurationSection section = SharedConfiguration.GetSection("JwtBearer"); builder.AddJwtBearer(options => { options.Authority = section.GetValue <string>("Authority"); if (options.Authority == null) { options.Authority = SharedConfiguration.GetOidcLink(); } options.RequireHttpsMetadata = section.GetValue <bool>("HttpsMetadata"); options.Audience = section.GetValue <string>("Audience"); }); return(services); }