To get a token from an Azure AD registered app using MSAL in a Blazor WebAssembly app, you can follow the instructions in the tutorial Tutorial: Sign in users and call a protected API from a Blazor WebAssembly app and modify the code to get a token for your registered app instead of Graph. Specifically, you will need to modify the OnInitializedAsync
method in the Index.razor
file to use the AcquireTokenAsync
method of the IPublicClientApplication
interface to get a token for your registered app. You will also need to modify the apiAuthorizationMessageHandler
in the Program.cs
file to use the AddAccessToken
method of the AccessTokenProvider
class to add the token to the HTTP request headers.
References: