dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.34k stars 9.98k forks source link

Blazor WASM "Error trying to log you in" on Net 5 and 6 in VS 2022 #39201

Open dochoss opened 2 years ago

dochoss commented 2 years ago

Is there an existing issue for this?

Describe the bug

When creating a new Blazor WASM project with authentication set to "Microsoft Identity Platform", with HTTPS checked, and with and without PWA checked (both tested), login fails with "There was an error trying to log you in: '' ". I've seen the other errors posted that include a "toLowerCase" related error, but this error doesn't show that. I'm getting a 400 - Bad Request error when calling the token endpoint during the login process (https://login.microsoftonline.com/<my tenant id>/oauth2/v2.0/token).

The only change I made to the default project file is to add Azure AD info to the appsettings.json file in wwwroot. I've tried with .Net 5 and 6 in the latest versions, and made sure to update VS 2022 to the latest version. I've tried cleaning out the bin and obj folders multiple times, and have tried multiple browsers (Edge, Chrome, and Brave). I saw on other posts the workaround of excluding the auth package from trimming (as here: https://github.com/dotnet/aspnetcore/issues/37206#issuecomment-974208499) but that didn't have any effect.

In my local network, I have a Pi-Hole for ad filtering, but login.microsoftonline.com is whitelisted, and I've tried logging in to the Blazor app with Pi-Hole totally disabled and that has the same result as above. Other than Pi-Hole, I have nothing between my machine and the internet.

Repro repo is here: https://github.com/dochoss/blazor-wasm-login-error.git

Expected Behavior

User logs in successfully

Steps To Reproduce

  1. Clone repo
  2. Update AzureAd object in appsettings.json
  3. Run
  4. Attempt to log in

Exceptions (if any)

I see this in the Output window in VS 2022:

The program '[35560] dotnet.exe' has exited with code 4294967295 (0xffffffff).

.NET Version

6.0.101

Anything else?

VS Community 2022 v17.0.4

Results of dotnet --info:

.NET SDK (reflecting any global.json):
 Version:   6.0.101
 Commit:    ef49f6213a

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

Host (useful for support):
  Version: 6.0.1
  Commit:  3a25a7f1cc

.NET SDKs installed:
  3.1.101 [C:\Program Files\dotnet\sdk]
  3.1.200 [C:\Program Files\dotnet\sdk]
  3.1.201 [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]
  5.0.201 [C:\Program Files\dotnet\sdk]
  5.0.400 [C:\Program Files\dotnet\sdk]
  6.0.101 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.29 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.29 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.18 [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.AspNetCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.29 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.5 [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 3.1.18 [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.NETCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.3 [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 3.1.18 [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]
  Microsoft.WindowsDesktop.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download
pranavkm commented 2 years ago

Could you include the logs from the browser Developer console?

ghost commented 2 years ago

Hi @dochoss. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

dochoss commented 2 years ago

HAR file from dev console attached. Let me know what else I can provide.

Scholar-LoginProcess-BlazorWASM.zip

pranavkm commented 2 years ago

@dochoss sorry I didn't mean the network log. The developer console will typically include logs or exception stack traces, if any. Is it entirely empty?

dochoss commented 2 years ago

Sorry, no, there is no other information in the console.

mkArtakMSFT commented 2 years ago

Thanks for additional details, @dochoss. We know it's hard to investigate such issues and have created this issue to try to improve that area.

ghost commented 2 years ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

dochoss commented 2 years ago

@mkArtakMSFT Thanks for letting me know. I really want to love Blazor, as I'm mostly a C# dev, I just keep running into frustrating issues like this when spinning up new projects. I built my first Blazor app on version 0.1, so I've seen it mature and I'm still very excited about its future! I'll keep following and trying whenever new projects crop up. Thanks to you and the team for your work!

ghost commented 10 months ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.