我正在设置不使用Microsoft身份验证的ASP.NET Core身份验证的社会登录提供程序身份验证。链接的教程以Google为例,提供了用于获取其身份验证方案的代码DefaultChallengeScheme
。
Microsoft的身份验证方案是什么?我一直找不到。
我的Startup.cs> ConfigureServices方法:
public void ConfigureServices(IServiceCollection services)
{
//set up using this tutorial https://docs.microsoft.com/en-us/aspnet/core/security/authentication/social/social-without-identity?view=aspnetcore-2.2
services
.AddAuthentication(authenticationOptions =>
{
authenticationOptions.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
authenticationOptions.DefaultChallengeScheme = //??? what goes here
})
.AddCookie()
.AddMicrosoftAccount(microsoftOptions =>
{
microsoftOptions.ClientId = Configuration["Authentication:Microsoft:ClientId"];
microsoftOptions.ClientSecret = Configuration["Authentication:Microsoft:ClientSecret"];
});
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
}
用于身份验证方案的文字值是Microsoft
。您可以使用常量访问此值MicrosoftAccountDefaults.AuthenticationScheme
:
authenticationOptions.DefaultChallengeScheme =
MicrosoftAccountDefaults.AuthenticationScheme;
这是常量的来源:
public static class MicrosoftAccountDefaults { public const string AuthenticationScheme = "Microsoft"; // ... }
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句