Share via

Azure AD B2C - ASP.Net Core Angular Application - Error while acquiring token for downstream Web API

Cerebral Calm 5 Reputation points
2023-06-10T05:55:13.1666667+00:00

I have a SPA that uses Azure AD B2C and MSAL libraries. SPA is part of a ASP.Net Core Angular Application. So, the application has .Net Controller that connects to the other azure hosted Web APIs. When angular code makes a HTTP call to the controller, MSAL interceptor kicks in and sends the token across. But, when I try to get the token using tokenAcquisition.GetAccessTokenForUserAsync, I get error. Can you please advise what is going wrong here.

I have followed this code sample on GitHub

 https://github.com/Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2/tree/master/4-WebApp-your-API/4-2-B2C#how-to-secure-a-web-api-built-with-aspnet-core-using-the-azure-ad-b2c

fail: Microsoft.Identity.Web.TokenAcquisition[0]

Microsoft.Identity.Web.TokenAcquisition: Error: False MSAL 4.54.1.0 MSAL.NetCore .NET 7.0.4 Darwin 22.1.0 Darwin Kernel Version 22.1.0: Sun Oct  9 20:14:54 PDT 2022; root:xnu-8792.41.9~2/RELEASE_X86_64 [2023-06-10 05:37:32Z - 867a5621-fbcc-4cd4-8533-692ba502c3de] Exception type: Microsoft.Identity.Client.MsalUiRequiredException

, ErrorCode: user_null

HTTP StatusCode 0

Microsoft Security | Microsoft Entra | Microsoft Entra External ID
Microsoft Security | Microsoft Entra | Microsoft Entra ID
{count} votes

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.