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

Multiple authentication methods in Blazor 8 wont 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 cant login with credentials by Username and Password.Now i only will be redirected to "home" but i am not logged in.

What i am doing wrong?Thanks in advanced.

I have try so many things founded. 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>