Aspnetcore: Azure B2C Blazor WASM not working without implicit grant settings (some property missing)

Created on 12 Oct 2020  路  5Comments  路  Source: dotnet/aspnetcore

Describe the bug

I try azure template for B2C Blazor WASM but it is not working without implicit grant settings

Fixes

Microsoft.Authentication.WebAssembly.Msal version 3.2.1 missing 2 properties
in MsalProviderOptions.cs

public string LoginMode { get; set; } = "popup";

and in MsalAuthenticationOptions.cs

public IList<string> KnownAuthorities { get; set; } = new List<string>();
  • Have to use msal-browser 2 not msal-browser 1.x.x in package.json
"@azure/msal-browser": "^2.0.0"

To Reproduce

https://docs.microsoft.com/en-us/aspnet/core/blazor/security/webassembly/hosted-with-azure-active-directory-b2c?view=aspnetcore-3.1

Further technical details

  • ASP.NET Core version 3.1
  • Include the output of dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   3.1.300
 Commit:    b2475c1295

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.18363
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.1.300\

Host (useful for support):
  Version: 5.0.0-rc.1.20451.14
  Commit:  38017c3935

.NET SDKs installed:
  3.1.300 [C:\Program Files\dotnet\sdk]
  3.1.402 [C:\Program Files\dotnet\sdk]
  5.0.100-rc.1.20452.10 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0-rc.1.20451.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.18 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.21 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0-rc.1.20451.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.0-rc.1.20452.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  • The IDE VS 16.8.0 Preview 3.1
Answered Resolved area-blazor blazor-wasm

Most helpful comment

@mkArtakMSFT Please reopen.

If 3.1 isn't supported then why bother making 3.1 templates?

https://developer.microsoft.com/en-us/identity/blogs/microsoft-identity-web-is-now-generally-available/

Explicitly references 3.1 templates.

image

All 5 comments

Thanks for contacting us. We've added support for this in .NET 5.0. Please update to the latest RC release.

@mkArtakMSFT Please reopen.

If 3.1 isn't supported then why bother making 3.1 templates?

https://developer.microsoft.com/en-us/identity/blogs/microsoft-identity-web-is-now-generally-available/

Explicitly references 3.1 templates.

image

@mkArtakMSFT Thanks for your reply. But if dotnet 3.1 is not supported, then why doen't Azure say supported only for dotnet 5? A few small changes in one typescript file I think can fix it.

Anyone has the same problem and want to use 3.1 can use this modified JS

https://github.com/ShadyNagy/b2c-blazor-wasm-31

@ShadyNagy Seems to be working for me. Thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Pixel-Lord picture Pixel-Lord  路  3Comments

farhadibehnam picture farhadibehnam  路  3Comments

ipinak picture ipinak  路  3Comments

guardrex picture guardrex  路  3Comments

markrendle picture markrendle  路  3Comments