I've developed an mvc 5 application and i use facebook login using External callback it was working well but now it is not working and i can't find out actual problem. And i find out why AuthenticationManager.GetExternalLoginInfoAsync(); is returning null value i used all most all the solution in my application but still have this problem. I remove session and set cookies but not effected.
I installed Facebook 6.4.0 from nuget to use FacebookClient to get user created events from facebook still it's working but i don't know what was happened know it's not working and returning null.
In Startup.Auth
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
Provider = new CookieAuthenticationProvider
{
// Enables the application to validate the security stamp when the user logs in.
// This is a security feature which is used when you change a password or add an external login to your account.
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
validateInterval: TimeSpan.FromDays(1),
regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
},
ExpireTimeSpan = TimeSpan.FromDays(2)
});
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
Set Facebook app id and app secret in Startup.Auth
app.UseFacebookAuthentication(
appId: "my app id",
appSecret: "my app secret"
);
In login i use this below code.
[AllowAnonymous]
public async Task<ActionResult> ExternalLoginCallback(string returnUrl)
{
var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();
if (loginInfo == null)
{
return RedirectToAction("Login");
}
}