signInManager.IsSignedIn return false but SignInAsync was called

249 views Asked by At

I'm try to add oAuth to my .net core application. I have that code in Startup.cs

 services
            .AddAuthentication( options =>
            {
                options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                options.DefaultChallengeScheme = MicrosoftAccountDefaults.AuthenticationScheme;
            } )
            .AddCookie()
            .AddMicrosoftAccount( microsoftOptions =>
            {
                microsoftOptions.ClientId = "...";
                microsoftOptions.ClientSecret = "...";
                microsoftOptions.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
            } );

And then in callback handler I try to authorize user like this

await _signInManager.SignInAsync( user, new AuthenticationProperties { IsPersistent = true, AllowRefresh = true } );

After that, try to call signInManager.IsSignedIn(HttpContext.User) but it's return false.

I think problem in the signInManager, because his AuthorizationScheme use another cookie state or something like that

0

There are 0 answers