工作在Startup.Auth.csASP.NET MVC 5外部登录不在现场工作,但在本地主机
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");
}
LOGININFO总是空的Facebook和我检查了Facebook的授权后的FB ID和秘密已经
我重定向与error=access_denied
到externallgincallback,我看到 loginInfo is null
http://example.com/account/externallogincallback?error=access_denied#=
它在没有SSL的本地主机上工作,我会尝试等待其他解决方案,因为SSL代价高昂 –
因为它是本地主机,Facebook知道你要测试你的应用程序。 –
我不确定,但我认为没有其他解决方案,因为安全问题 –