I'm trying to setup Facebook authentication with dot-net core 2.0, but in my ExternalLoginCallbackAsync method, I'm always getting null as a response I have followed the documentation and so far this is what I've done:
in my ConfigureServices in the startup file:
services.AddAuthentication(
options => options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme);
services.AddAuthentication().AddFacebook(
f => {
f.AppId = Configuration["facebook-app-id"];
f.AppSecret = Configuration["facebook-app-secret"];
});
in my login controller:
public IActionResult ExternalLogin(string provider)
{
var authProperties = new AuthenticationProperties
{
RedirectUri = Url.Action("ExternalLoginCallbackAsync", "Login")
};
return Challenge(authProperties,provider);
}
in my ExternalLoginCallbackAsync method when I do
var info = await _signInManager.GetExternalLoginInfoAsync();
any hint why am I always getting null?
thanks
I looked at the SignInManager code as Lasse Vabe Rolstad suggested and for me, a key was missing in the auth properties so I had to add it manually like this:
var authProperties = new AuthenticationProperties
{
RedirectUri = Url.Action("ExternalLoginCallbackAsync", "Login"),
Items = { new KeyValuePair<string, string>("LoginProvider",provider) }
};