Identityserver4: Using docs SigninManager.GetExternalLoginInfoAsync() returns null with external

Created on 29 Oct 2016  路  8Comments  路  Source: IdentityServer/IdentityServer4

Hi there,

Was following along with the docs. I am using the ASP.net Core Individual Auth template and I added my external providers, however I'm having issues on the login screen using them when they're configured the way the docs show.

https://identityserver4.readthedocs.io/en/dev/quickstarts/4_external_authentication.html

In those docs it says to configure the provider like so:

app.UseGoogleAuthentication(new GoogleOptions
{
    AuthenticationScheme = "Google",
    DisplayName = "Google",
    SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme,

    ClientId = "<Secret>",
    ClientSecret = "<Secret>"
});

However, when I do this, when attempting to click the button on the login screen, it calls into ExternalLoginCallback and makes this call:

var info = await _signInManager.GetExternalLoginInfoAsync();

GetExternalLoginInfoAsync() returns null here.

Knowing that this worked fine in a project I had done I compared and saw the SignInScheme was not defined in my project so I commented it out. Sure enough it works.

So if I leave out SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme, then everything works as expected.

I defined the Cookie per the docs as

            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme,
                AutomaticAuthenticate = false,
                AutomaticChallenge = false                
            });

Am I missing something? Are the docs wrong? Or some other issue?

Thanks!

question

Most helpful comment

something like:

services.AddIdentity(options=>{
   options.Cookies.ExternalCookie.AuthenticationScheme = "SomeName";
});

All 8 comments

The ASP.NET Identity library also needs to know that scheme. Configure it on the AddIdentity helper.

Thanks, can you show maybe what that would look like? I'm not seeing any setter in there for scheme. Anything I'm finding is read only?

something like:

services.AddIdentity(options=>{
   options.Cookies.ExternalCookie.AuthenticationScheme = "SomeName";
});

Dang it! I did that I thought, but it said it was read only :-| Thank you.

You should add that to the docs in that section because as they stand now it doesn't work. Though technically you could remove overwriting the scheme, right? It worked because I just had it as default which appears to be "Identity.External"

In our AspId3 sample we allow the AspId3 framework to register the external cookie middleware, so we don't use the "Identity.External" one.

As for the docs, we do accept PRs so if you find a good place for this info, please add it.

Removing this line from the client MVC app solved the problem with the GetExternalLoginInfoAsync returning null.

JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings