I have a Blazor WebAssembly Standalone App that is configured to use authentication. This seems to work. I also have an Azure Function that requires authentication. When I log in to https://.azurewebsites.net/.auth/login/aad, everything works through the browser. However, I'm unsure how to perform authentication for the Azure Functions app through the Blazor WebAssembly Standalone App. I always get a 401.
I've tried posting the access token from the Blazor WebAssembly Standalone App to https://.azurewebsites.net/.auth/login/aad, but I get a 401. I've also tried including the access token in the Authorization header, as a Bearer token, when performing a get to the Azure Function, but I also get a 401.
This is a common scenario, no? Perhaps my Google and Copilot skills just aren't up to snuff?
As per the request of Harshitha, here is my project file:
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly"><PropertyGroup><TargetFramework>net8.0</TargetFramework><Nullable>enable</Nullable><ImplicitUsings>enable</ImplicitUsings></PropertyGroup><ItemGroup><PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.4" /><PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.4" PrivateAssets="all" /><PackageReference Include="Microsoft.Authentication.WebAssembly.Msal" Version="8.0.4" /></ItemGroup></Project>