I am migrating from ADAL to MSAL then getting the Unauthorized error when passing token into my api. (using React and .NET core ( .NET core 2.1 framework)
- UIClient application is already registered then I have added SPA and add redirecturl.
- Registered API application has added UIClient ClientId into Expose API -> Authrozied client application
- MSAL is able to generate the token.
- Sending token to API (using .Net core 2.1 framework)
- Failed in authorizing the token, getting 401 unauthorized error from API code.
appsetting.json file contain setting
AzureAd{
Authority: "https://login.microsoftonline.com/common",
ValidClientIds: ["Guid1","Guid2"],
"AllowedIssuers: ["stsurl1","stsurl2"]
}
Startup.cs code
services.AddAuthentication(opt => {opt.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;}).AddAzureAdBearer(opt2 => configuration.Bind("AzureAd", opt2)); ```