在Startup.Auth.cs
中app.UseFacebookAuthentication(
appId: "xxxxxx",
appSecret: "xxxxxx");
app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
{
ClientId = "ssssss",
ClientSecret = "sssss"
});
在我的本地主机中谷歌和Facebook外部登录都正常工作,但在我的直播网站facebook不是。在我的实际网站中,当用户点击Facebook登录时,它会提示许可,但它会返回登录,我认为它返回null
public async Task<ActionResult> ExternalLoginCallback(string returnUrl)
{
var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();
if (loginInfo == null)
{
return RedirectToAction("Login");
}
// Sign in the user with this external login provider if the user already has a login
var result = await SignInManager.ExternalSignInAsync(loginInfo, isPersistent: false);
switch (result)
{
case SignInStatus.Success:
return RedirectToLocal(returnUrl);
case SignInStatus.LockedOut:
return View("Lockout");
case SignInStatus.RequiresVerification:
return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = false });
case SignInStatus.Failure:
default:
// If the user does not have an account, then prompt the user to create an account
ViewBag.ReturnUrl = returnUrl;
ViewBag.LoginProvider = loginInfo.Login.LoginProvider;
var viewModel = new ExternalLoginConfirmationViewModel
{
Email = loginInfo.Email
};
ViewBag.Title = "Register";
return View("ExternalLoginConfirmation", viewModel);
}
}
有什么想法吗?我的实际网站没有使用ssl。
更新
public async Task<ActionResult> ExternalLoginCallback(string returnUrl)
{
var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();
if (loginInfo == null)
{
return Content("loginInfo is null");
}
对于facebook,loginInfo始终为null,我已经检查了fb id和secret
在facebook授权后,我被error=access_denied
重定向到externallgincallback,我明白了
loginInfo is null
http://example.com/account/externallogincallback?error=access_denied#=
答案 0 :(得分:0)
我认为您应该为您的网站使用有效的SSL证书。
更新
我的回答是错误的。 Heero Yuy说:
我与托管服务提供商谈过,导致问题的是他们的安全功能。以下是他们的回复:由于大量不良用户运行Facebook-Bots,我们阻止了对Facebook网络的所有传出访问(例如graph.facebook.com)。