【发布时间】:2021-10-18 15:41:33
【问题描述】:
我正在尝试修改我的 AzureAd 身份验证以使用 SignalR。所以我更改了身份验证,以便添加更多选项。
在我使用 services.AddMicrosoftIdentityWebApiAuthentication(Configuration, "AzureAd"); 之前,它运行良好。
据此https://docs.microsoft.com/en-us/azure/active-directory/develop/scenario-protected-web-api-app-configuration#:~:text=you%20can%20also%20write%20the%20following%20(which%20is%20equivalent)
我应该可以使用services.AddAuthentication(AzureADDefaults.JwtBearerAuthenticationScheme) .AddMicrosoftIdentityWebApi(Configuration, "AzureAd");
但是,当我点击我的 API 时,我得到了 System.InvalidOperationException: No authenticationScheme was specified, and there was no DefaultChallengeScheme found. The default schemes can be set using either AddAuthentication(string defaultScheme) or AddAuthentication(Action<AuthenticationOptions> configureOptions).。
【问题讨论】:
-
你在 startup.cs 中需要这个: services.AddAuthentication(AzureADDefaults.AuthenticationScheme) .AddAzureAD(options => Configuration.Bind("AzureAd", options));
标签: c# asp.net authentication azure-active-directory