Microsoft/Facebook身份验证的高级功能在Asp .Net Core RC1上不可用 [英] Advanced features of Microsoft/Facebook authentifcation not available on Asp .Net Core RC1

查看:72
本文介绍了Microsoft/Facebook身份验证的高级功能在Asp .Net Core RC1上不可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm working on a small ASP .NET Core RC1 application and I'm trying to implement the Microsoft/Facebook authentification.

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

The following tutorial is really great and explain all the steps needed: http://www.oauthforaspnet.com/providers/microsoft/

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

But if I try to use the "advanced" features (like using the Provider property), this one is not available. I've added the following Nuget references in project.json:

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

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

但是我无法使用FacebookAuthenticationProvider/FacebookProvider.

But I'm not able to use the FacebookAuthenticationProvider / FacebookProvider.

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

According to my research over the Net, it looks like that was possible using Beta 7 / Beta 8 but does anyone have successfully implemented the feature in RC 1?

谢谢!

推荐答案

在ASP.NET Core 1.x中,所有OAuth2社交提供程序(

In ASP.NET Core 1.x, all the OAuth2 social providers (even the ones developed by the community) have been updated to use the new OAuth2 generic middleware.

作为此更改的一部分,我们已删除了特定于提供程序的类,以使用单个名为OAuthEvents 的事件钩子,它替换了Katana的FacebookAuthenticationProvider和co.

As part of this change, we've removed the provider-specific classes to use a single events hook named OAuthEvents, which replaces Katana's FacebookAuthenticationProvider and co.

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

Here's an example using the Google provider:

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);
        }
    }
});

这篇关于Microsoft/Facebook身份验证的高级功能在Asp .Net Core RC1上不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆