Asp.net core 使用Microsoft.Identity.Web将Asp.Net Core 2.2升级到3.1-未为方案注册任何身份验证处理程序';AzureADJwtBearer';

Asp.net core 使用Microsoft.Identity.Web将Asp.Net Core 2.2升级到3.1-未为方案注册任何身份验证处理程序';AzureADJwtBearer';,asp.net-core,.net-core,msal,Asp.net Core,.net Core,Msal,我正在将Asp.NETCore2.2应用程序更新为3.1 我们使用Microsoft.Identity.Web处理Azure广告身份验证。我更改了我们的安全配置,如下所示: 配置系列 services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddMicrosoftIdentityWebApi(configuration) .EnableTokenAcquisitionToCallDownstreamA

我正在将Asp.NETCore2.2应用程序更新为3.1

我们使用Microsoft.Identity.Web处理Azure广告身份验证。我更改了我们的安全配置,如下所示:

配置系列

services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
    .AddMicrosoftIdentityWebApi(configuration)
    .EnableTokenAcquisitionToCallDownstreamApi()
    .AddInMemoryTokenCaches();

services.AddAuthentication()
    .AddScheme<ApiKeyAuthenticationSchemeOptions, ApiKeyAuthenticationHandler
    (AuthenticationSchemes.ApiKey, null);
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApi(配置)
.EnableTokenAcquisitionTollDownstreamMapi()
.AddInMemoryTokenCaches();
services.AddAuthentication()
.AddScheme
{
p、 映射控制器();
});
但是抛出以下异常

System.InvalidOperationException
  HResult=0x80131509
  Message=No authentication handler is registered for the scheme 'AzureADJwtBearer'. The registered schemes are: Bearer, ApiKey. Did you forget to call AddAuthentication().Add[SomeAuthHandler]("AzureADJwtBearer",...)?
  Source=Microsoft.AspNetCore.Authentication.Core
  StackTrace:
   at Microsoft.AspNetCore.Authentication.AuthenticationService.<AuthenticateAsync>d__13.MoveNext() in /_/src/Http/Authentication.Core/src/AuthenticationService.cs:line 67
System.invalidoOperationException
HResult=0x80131509
消息=没有为方案“AzureAdjWTBearrer”注册任何身份验证处理程序。注册的方案有:无记名、ApiKey。您是否忘记调用AddAuthentication()。添加[SomeAuthHandler](“AzureAdjWTBearner”,…)?
Source=Microsoft.AspNetCore.Authentication.Core
堆栈跟踪:
在/\uu/src/Http/Authentication.Core/src/AuthenticationService.cs中的Microsoft.AspNetCore.Authentication.AuthenticationService.d_u13.MoveNext()中:第67行
不确定哪个部分未注册身份验证/授权设置


谢谢,

问题出在我们的代码中,我们使用了一个带有常量字符串的类来返回ApiKey、AzureAdjwtBear或All作为控制器的身份验证方案,但AzureAdjwtBear已被替换为just Bear

谢谢,

System.InvalidOperationException
  HResult=0x80131509
  Message=No authentication handler is registered for the scheme 'AzureADJwtBearer'. The registered schemes are: Bearer, ApiKey. Did you forget to call AddAuthentication().Add[SomeAuthHandler]("AzureADJwtBearer",...)?
  Source=Microsoft.AspNetCore.Authentication.Core
  StackTrace:
   at Microsoft.AspNetCore.Authentication.AuthenticationService.<AuthenticateAsync>d__13.MoveNext() in /_/src/Http/Authentication.Core/src/AuthenticationService.cs:line 67