Skip to content

Can you combine multiple authentication schemes? Cookie & Bearer #1579

Answered by ystvan
ystvan asked this question in Q&A
Discussion options

You must be logged in to vote

Found out, yes you can combine, but then have to explicitly say which one is the default :)

        // Add authentication with Microsoft identity platform.
        services
            .AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
            .AddMicrosoftIdentityWebApp(configuration)
            .AddDistributedTokenCaches();

        services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
                .AddMicrosoftIdentityWebApi(configuration);

        // Have to add the default explicitly since we are using multiple schemas
        services.AddAuthentication(options =>
        {
            options.DefaultAuthenticateScheme = OpenIdConnectDefaults.Authent…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jmprieur
Comment options

Answer selected by ystvan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants