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);
So in my ExternalLoginCallback method AuthenticationManager.GetExternalLoginInfoAsync()
used to work just fine, then suddenly a few days ago it no longer does anything and returns NULL, causing the entire “Register with Facebook” process to be skipped, redirecting the user to the Login page.
I had a separate ASP.NET MVC5 project that I made just to play around witth the Facebook Graph API and when I went back to it (I left it 2 weeks ago and the register/login with Facebook worked just fine on this project) it had the same problem, it returned null ! redirecting the user to the login page.
Is it possible there is something with my Facebook App ? or their API ? I have failed the app review 3 times (had some problems further down the code), put it back to development mode to try to work it out and now its not even hitting the previous problem, it stops at the AuthenticationManager.GetExternalLoginInfoAsync()
and I cannot understand whats going on since I did not have this problem last week.
Here is the ExternalLogin method:
public ActionResult ExternalLogin(string provider, string returnUrl)
{
ControllerContext.HttpContext.Session.RemoveAll();
return new ChallengeResult(provider, Url.Action("ExternalLoginCallback", "Account", new { ReturnUrl = returnUrl }));
}
I’ve added ControllerContext.HttpContext.Session.RemoveAll();
to a suggestion I’ve found here on stackoverflow but it doesn’t seem to do anything.
3
Answers
Had to update the Microsoft Owin package to 3.1.0-rc1 and now it works. (have the "include prerelease" in your update tab in the package manager)
There was a change on Facebook’s side which caused Facebook logins for web and mobile apps using Azure App Service Authentication / Authorization to stop working.
There is now a hotfix which was rolled out to most sites.
https://social.msdn.microsoft.com/Forums/azure/en-US/397f6952-57bf-4c28-b383-6bba08d28f9a/facebook-login-failures-with-app-service-authentication-authorization?forum=windowsazurewebsitespreview
Try to update all nuget packages, this helps for me.