繁体   English   中英

Asp.Net身份:用facebook登录

[英]Asp.Net Identity: Login with facebook

我按照these instructions在我的解决方案中创建了一个ASP.Net MVC项目

在成功使用自定义IUserStore登录并创建用户IUserStore ,我按照these instructions进行these instructions以允许使用诸如facebook之类的社交网络登录:

不幸的是,这样做之后,我意识到登录无效,因为此代码只是挂起了:

private async Task SignInAsync(User user, bool isPersistent)
    {
        AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);
        var identity = await UserManager.CreateIdentityAsync(user, 
                                DefaultAuthenticationTypes.ApplicationCookie);
        AuthenticationManager.SignIn(new AuthenticationProperties() { 
                           IsPersistent = isPersistent }, identity);
    }

我尝试进入或寻找有关它的文档,但是我有点迷路了...

identity = await UserManager.CreateIdentityAsync(user, 
                     DefaultAuthenticationTypes.ApplicationCookie);

有任何想法吗?

编辑:我正在使用.net Framework 4.5,MVC v5和Visual Studio 2013

您可以尝试本教程

它很简单,对我来说效果很好。

something like that: 如果您想从Facebook提供商处索取更多信息,只需在添加如下内容:

FacebookAuthenticationOptions facebookOptions = new FacebookAuthenticationOptions()
{
    AppId = "PutYourFacebookAppIdHere",
    AppSecret = "PutYourFacebookAppSecretHere"
};
facebookOptions.Scope.Add("email");
app.UseFacebookAuthentication(facebookOptions);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM