工作在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知道你要測試你的應用程序。 –
我不確定,但我認爲沒有其他解決方案,因爲安全問題 –