In Startup.Auth.cs
app.UseFacebookAuthentication(
appId: "xxxxxx",
appSecret: "xxxxxx");
app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
{
ClientId = "ssssss",
ClientSecret = "sssss"
});
In my localhost both google and facebook external login are working but in my live site facebook is not. In my live site when a user clicks facebook login it will prompt for permission but it will just go back to Login, I think it's returning 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);
}
}
Any idea? My live site is not using ssl.
Update:
public async Task<ActionResult> ExternalLoginCallback(string returnUrl)
{
var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();
if (loginInfo == null)
{
return Content("loginInfo is null");
}
loginInfo is always null for facebook and i've checked the fb id and secret already
after facebook authorization i get redirected to externallgincallback with error=access_denied
and i see loginInfo is null
http://example.com/account/externallogincallback?error=access_denied# =
I think you should use a valid SSL Certificate for your website.
Update.
My answer was wrong. Heero Yuy said:
I talked with the hosting provider it was their security features that caused the problem. Here is their response: We are blocking all outgoing access to Facebook's network(eg graph.facebook.com) due to large number of bad users running Facebook-Bots.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.