2017-03-24 68 views
0

工作在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#=

回答

0

我认为你应该为你的网站使用有效的SSL证书。

更新。

我的回答是错误的。 Heero Yuy说:

我跟托管服务提供商讨论过,这是他们的安全功能导致的问题。这是他们的回应:由于运行Facebook-Bots的大量坏用户,我们阻止了所有对Facebook网络的传出访问(例如graph.facebook.com)。

+0

它在没有SSL的本地主机上工作,我会尝试等待其他解决方案,因为SSL代价高昂 –

+0

因为它是本地主机,Facebook知道你要测试你的应用程序。 –

+0

我不确定,但我认为没有其他解决方案,因为安全问题 –

相关问题