C# 在.net核心WEB API中为每个请求动态分配身份验证选项
我希望通过Azure AD B2C保护我的web API。我使用appsettings保留选项,并按以下代码注册它们C# 在.net核心WEB API中为每个请求动态分配身份验证选项,c#,.net,asp.net-core,authentication,azure-ad-b2c,C#,.net,Asp.net Core,Authentication,Azure Ad B2c,我希望通过Azure AD B2C保护我的web API。我使用appsettings保留选项,并按以下代码注册它们 public void ConfigureServices(IServiceCollection services) { services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddMicrosoftIdentityWebApi(options => {
public void ConfigureServices(IServiceCollection services)
{
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApi(options =>
{
Configuration.Bind("AzureAdB2C", options);
options.TokenValidationParameters.NameClaimType = "name";
},
options => { Configuration.Bind("AzureAdB2C", options); });
}
我想做的是: