身份提供商ASP.NET Facebook身份验证不起作用
问题描述:
我正在使用Microsoft的身份框架来使用外部登录名。除了Facebook以外,所有其他人都在工作。当我使用Facebook时,让我登录,但不要求获得许可,并立即将我返回登录页面,而无需获得授权。身份提供商ASP.NET Facebook身份验证不起作用
回调URL是http://localhost:14613/signin-facebook/
这是我的外部登录验证码(通过ID和秘密中空白):
app.UseFacebookAuthentication(
appId: "XXXXXXX",
appSecret: "XXXXXXX"
);
预期的结果是,它将我重定向到:本地主机/客户/ ExternalLoginSucceeded
答
我也有过类似的问题,虽然解决了,同时更新以下的NuGet包:
-
个
- Microsoft.Owin到3.1.0版本
- Microsoft.Owin.Security到版本3.1.0
- Microsoft.Owin.Security.Cookies到版本3.1.0
- Microsoft.Owin.Security.OAuth到版本3.1.0
- Microsoft.Owin.Security.Facebook到版本3.1.0
Startup.cs代码:
var facebookOptions = new FacebookAuthenticationOptions()
{
AppId = "xxxxxx",
AppSecret = "xxxxxx",
Scope = { "email" },
Provider = new FacebookAuthenticationProvider()
{
OnAuthenticated = (context) =>
{
context.Identity.AddClaim(new Claim("urn:facebook:accesstoken", context.AccessToken, ClaimValueTypes.String, "Facebook"));
return Task.FromResult(0);
}
}
};
app.UseFacebookAuthentication(facebookOptions);
而且我的Facebook图形API的版本是2.8
答
首先你桅杆有Owin版本:
3.1.0
安装了的NuGet
我发现了一些类似的解决方案,我改变它并更新它以获得更多的Facebook用户喜欢的其它功能和是伟大的工作
这里是代码(粘贴Startup.Auth):
var facebookOptions = new FacebookAuthenticationOptions()
{
AppId = "-----copy from your facebook app-----",
AppSecret = "-----copy from your facebook app-----",
Provider = new FacebookAuthenticationProvider
{
OnAuthenticated = context =>
{
context.Identity.AddClaim(new System.Security.Claims.Claim("FacebookAccessToken", context.AccessToken));
return Task.FromResult(true);
}
},
//BackchannelHttpHandler = new FacebookBackChannelHandler(),
//UserInformationEndpoint = "https://graph.facebook.com/v2.4/me?fields=id,name,email,first_name,last_name,location"
};
facebookOptions.Scope.Add("email");
//facebookOptions.Scope.Add("user_likes");
app.UseFacebookAuthentication(facebookOptions);
固定我的问题 - 谢谢!进一步调查问题后,以下是停止工作的原因:https://github.com/aspnet/AspNetKatana/issues/38 – Rick