AuthenticationManager.GetExternalLoginInfoAsync () returns null on Facebook
I developed a mvc 5 app and I am using facebook login using External callback, it worked well but now it doesn't work and I can't find the actual problem. And I find out why AuthenticationManager.GetExternalLoginInfoAsync (); returns null. I've used all most of the solutions in my application, but still have this problem. I delete the session and set cookies, but not getting executed.
I installed Facebook 6.4.0 from nuget in order to use FacebookClient to receive user generated events from facebook, but still it works, but I don't know what happened, I know it doesn't work and returns 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 secret id and app in Startup.Auth
app.UseFacebookAuthentication(
appId: "my app id",
appSecret: "my app secret"
);
In login I am using this below code.
[AllowAnonymous]
public async Task<ActionResult> ExternalLoginCallback(string returnUrl)
{
var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();
if (loginInfo == null)
{
return RedirectToAction("Login");
}
}
source to share
No one has answered this question yet
See similar questions:
or similar: