Msal Error >> Failed To Acquire Token Silently From Broker

  Kiến thức lập trình

I have an Azure Active Directory set up, and I created an application where I obtained the tenant ID and client ID. In a C# console application, I use MSAL for authentication. If I use interactive mode, the Microsoft login window appears, and I can log in normally. However, my goal is to perform the login silently using the account that is currently logged into Windows. In this case, it’s a Microsoft account, and the email associated with this account belongs to the Active Directory. Nevertheless, I’m encountering an error:

ErrorCode: failed_to_acquire_token_silently_from_broker

Microsoft.Identity.Client.MsalUiRequiredException: WAM Error

Error Code: 3399548929*

Error Message: Need user interaction to continue.

The code that I’m using:

var app = PublicClientApplicationBuilder.Create(id).WithAuthority(AzureCloudInstance.AzurePublic, domain).WithBroker(new BrokerOptions(BrokerOptions.OperatingSystems.Windows)).Build();

var result = await app.AcquireTokenSilent(new[] { "User.Read" },PublicClientApplication.OperatingSystemAccount).ExecuteAsync();

Removing the “WithBroker” instruction results in the following error : “Only some brokers (WAM) can log in the current OS account.”

I have tried various versions without success, and I am leaning towards the possibility that it might be a configuration issue in Active Directory or User Account.

LEAVE A COMMENT