gpt4 book ai didi

asp.net - Microsoft/Facebook 身份验证的高级功能在 Asp .Net Core RC1 上不可用

转载 作者:行者123 更新时间:2023-12-02 18:23:21 27 4
gpt4 key购买 nike

我正在开发一个小型 ASP .NET Core RC1 应用程序,并尝试实现 Microsoft/Facebook 身份验证。

以下教程非常棒,并解释了所需的所有步骤: http://www.oauthforaspnet.com/providers/microsoft/

但是,如果我尝试使用“高级”功能(例如使用 Provider 属性),则此功能不可用。我在 project.json 中添加了以下 Nuget 引用:

“Microsoft.AspNet.Authentication.Facebook”:“1.0.0-rc1-final”,"Microsoft.AspNet.Authentication.MicrosoftAccount": "1.0.0-rc1-final",

但我无法使用 FacebookAuthenticationProvider/FacebookProvider。

根据我在网上的研究,看起来使用 Beta 7/Beta 8 是可能的,但有人在 RC 1 中成功实现了该功能吗?

谢谢!

最佳答案

在 ASP.NET Core 1.x 中,所有 OAuth2 社交提供程序 ( even the ones developed by the community ) 均已更新为使用新的 OAuth2 通用中间件。

作为此更改的一部分,we've removed the provider-specific classes to use a single events hook named OAuthEvents ,它取代了 Katana 的 FacebookAuthenticationProvider 和 co。

以下是使用 Google 提供商的示例:

app.UseGoogleAuthentication(new GoogleOptions
{
ClientId = "client_id",
ClientSecret = "client_secret",

Events = new OAuthEvents
{
OnCreatingTicket = context =>
{
// Extract the "language" property from the JSON payload returned by
// the user profile endpoint and add a new "urn:language" claim.
var language = context.User.Value<string>("language");
context.Identity.AddClaim(new Claim("urn:language", language));

return Task.FromResult(0);
}
}
});

关于asp.net - Microsoft/Facebook 身份验证的高级功能在 Asp .Net Core RC1 上不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35623873/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com