4

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");
    }
}
PixelDev
  • 273
  • 2
  • 11
  • Look at the following link http://stackoverflow.com/questions/22364442/asp-net-mvc5-owin-facebook-authentication-suddenly-not-working @sammy34 response. – RCalaf Mar 28 '17 at 10:42
  • Thank you @RCalaf for you answer i follow that step but still have this issue i think may be this is from facebook side because i run my other application same code and i facing same issue in that application also. – PixelDev Mar 28 '17 at 11:19
  • 1
    The solution is that see the @JayPi's solution. Noticed this problem yesterday. Facebook does not support Microsoft.Owin.Security.Facebook version 3.0.1 anymore. This is the latest stable NuGet Package. For me it worked to install version 3.1.0 RC1. To update to RC1, run the command Install-Package Microsoft.Owin.Security.Facebook -Pre in Package Manager Console: https://www.nuget.org/packages/Microsoft.Owin.Security.Facebook/3.1.0-rc1 – PixelDev Mar 30 '17 at 09:23

0 Answers0