Advanced features of Microsoft/Facebook authentifcation not available on Asp .Net Core RC1

醉酒当歌 提交于 2019-12-05 22:47:30

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.

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.

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);
        }
    }
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!