Luk*_*kas 5 c# asp.net authentication asp.net-core
我正在设置社交登录提供程序身份验证,无需使用 Microsoft 身份验证的 ASP.NET Core Identity。链接的教程使用 Google 作为示例,并提供了获取其身份验证方案的代码DefaultChallengeScheme
。
Microsoft 的身份验证方案是什么?我一直找不到它。
我的 Startup.cs > ConfigureServices 方法:
public void ConfigureServices(IServiceCollection services)
{
//set up using this tutorial https://learn.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);
}
Run Code Online (Sandbox Code Playgroud)
用于身份验证方案的文字值为Microsoft
。您可以使用常量访问该值MicrosoftAccountDefaults.AuthenticationScheme
:
authenticationOptions.DefaultChallengeScheme =
MicrosoftAccountDefaults.AuthenticationScheme;
Run Code Online (Sandbox Code Playgroud)
这是常量的来源:
Run Code Online (Sandbox Code Playgroud)public static class MicrosoftAccountDefaults { public const string AuthenticationScheme = "Microsoft"; // ... }
归档时间: |
|
查看次数: |
809 次 |
最近记录: |