2017-03-24 65 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

我不確定,但我認爲沒有其他解決方案,因爲安全問題 –

相關問題