GetExternalLoginInfoAsync return null value

1.5k views Asked by At

I am working on MVC core 2 and IdentityServer4, External user logged in successfully, the problem i'm facing is this function always return null in HomeController.

 var info = await _signInManager.GetExternalLoginInfoAsync();

But its working in AccountController, when user login and redirected back to client from IdentityServer.

public async Task<IActionResult> ExternalLoginCallback(string returnUrl = null, string remoteError = null)
{
    var info = await _signInManager.GetExternalLoginInfoAsync();
}

Any kind of help will be appreciated.

2

There are 2 answers

0
mackie On

It's all based on cookies so check that the cookie is being picked up correctly. I think be default it will set the path of the cookie and that may mean it is not sent to your AccountController because the path differs.

0
Jan ZahradnĂ­k On

My issue was in SignInScheme. When I commented the line below in Startup and use defaults it started to work.

services.AddAuthentication().AddGoogle("Google", opt =>
{
  //opt.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme;
  ...
}