Today I wasted more or less 2 hours for a stupid bug on a Blazor WASM hosted on ASP.NET Core app.
As always, it works on my machine.
I have created an application secure with Azure AD (and roles) and I use it for debugging for one month, without any issues.
When I tried to deployed everything on our test application on Azure, after the login, I obtained always the error:
login.microsoftonline.com/common/oauth2/v2.0/token:1 Failed to load resource: the server responded with a status of 400 (Bad Request)
At the beginning I thought that it was my fault because I recreated the App Registration from scratch before the deployment.
After an hard googling session, I found an issue on GitHub on the ASP.NET Core repository: https://github.com/dotnet/aspnetcore/issues/33312
Solution
- Edit the Client project file (double click on the project from Visual Studio 2022) and add the following lines:
<ItemGroup>
<TrimmerRootAssembly Include="Microsoft.Authentication.WebAssembly.Msal" />
</ItemGroup>
Delete all the "bin" and "obj" folders from the Server and App projects (manually)
Deploy the solution again and check the flag "Remove additional files at destination"
Enjoy your app with the Azure authentication :)
Top comments (0)