aspnetcore: .NET 8 preview7 Blazor WASM AAD authentication ends with There was an error trying to log you in: '"undefined" is not valid JSON'
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
I am getting the same issue as described in #44981 again: after coming back from login at Azure AD the user sees ‘There was an error trying to log you in: ‘“undefined” is not valid JSON’’ at the ‘authentication/login-failed’ route.
However, after manually navigating around the token is available so it kind-of worked anyway.
Same as with the previous issue, adding the following solves the issue, so I suspect a similar cause:
<ItemGroup>
<TrimmerRootAssembly Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" />
</ItemGroup>
Also: error does not appear during development, only after publish also pointing to the linker
Expected Behavior
No error should be displayed after the redirect if the operation was successful.
Steps To Reproduce
Standard Blazor WASM application using Microsoft.Authentication.WebAssembly.Msal
(8.0.0-preview.7.23375.9), set up to use ‘redirect’ and not the ‘pop up’ auth option.
Exceptions (if any)
No response
.NET Version
8.0.100-preview.7.23376.3
Anything else?
No response
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 4
- Comments: 16 (3 by maintainers)
Same issue on .NET 8 and I have tried adding both to the trimmer exception. Pushing this to .NET 9 is unacceptable. This has been going on long enough. It’s been years now.
In the
8.0.0
release:RemoteAuthenticatorView.LogInFailed
context (notably, downgrading MSAL to7.0.13
yields an error:"undefined" is not valid JSON
).Microsoft.Authentication.WebAssembly.Msal
when publishing the app resolves the issue immediately.I believe this should not be classified as “technical debt” for future “.NET 9 Planning”, but rather recognized as a regression that could potentially cause significant issues for users.
I can confirm. The issue is solved in our case by mentioning only one root assembly:
I experienced the same issue when upgrading to .NET 8.0 with Azure B2C. I had to add the following to get it to work.
Specifying just Microsoft.Authentication.WebAssembly.Msal alone did not work for me.
Thanks for contacting us.
We’re moving this issue to the
.NET 9 Planning
milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s). If we later determine, that the issue has no community involvement, or it’s very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.@czlatea Doesn’t work for me; tried both and just Authentication in both Client and Server projects using .net 8
Something that caught me out was I also needed to clear cache after adding
Edit: This actually didn’t fix it.
Using Net8.0, TrimmerRootAssembly does not fix the issue. Please help.
@kyleherzog Sorry for the confusion. Actually I do have both the MSAL and WebAssembly.Authentication rooted and it is probably the
Microsoft.AspNetCore.Components.WebAssembly.Authentication
which is the important one for this symptom.