Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Multiple authentication methods in Blazor 8 won't work

$
0
0

I try to add an authentication method in Blazor 8 but only the last method will work.

With the follwing code I am able to login with cookie:

...builder.Services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)    .AddMicrosoftIdentityWebApp(opts =>    {        builder.Configuration.GetSection("AzureAd").Bind(opts);    });builder.Services.AddAuthentication(options =>            {                options.DefaultScheme = IdentityConstants.ApplicationScheme;                options.DefaultSignInScheme = IdentityConstants.ExternalScheme;                options.DefaultSignOutScheme = IdentityConstants.ExternalScheme;            }).AddIdentityCookies();...

I can also see to button "OpenIdConnect". If I click the button, I can see it will try to login, but will redirect back to login. At the console I can see the log

IDX21310: OpenIdConnectProtocolValidationContext.ProtocolMessage.AccessToken is null, there is no 'token' in the OpenIdConnect Response to validate.

enter image description here

If I change my code like this:

... builder.Services.AddAuthentication(options =>             {                 options.DefaultScheme = IdentityConstants.ApplicationScheme;                 options.DefaultSignInScheme = IdentityConstants.ExternalScheme;                 options.DefaultSignOutScheme = IdentityConstants.ExternalScheme;             }).AddIdentityCookies();  builder.Services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)     .AddMicrosoftIdentityWebApp(opts =>     {         builder.Configuration.GetSection("AzureAd").Bind(opts);     });...

I am able to login with the Microsoft Account, but now I can't login with credentials by Username and Password.Now I only will be redirected to "home" but I am not logged in.

What am I doing wrong?

I like to login both with Microsoft Identity and over credentials by JWT or Cookies.


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>