I am writing a dotnet core console app that makes use of MSAL library to generate access token. I am making use of Integrated Windows Authentication as all the constraints that are mentioned in this link are satisfied by the organization I am in. This seems to work fine with MSAL 4.15.0 library version. But once I start using MSAL 4.16.0 version, I end up getting the following exception.
Inner Excception: MSAL.NetCore.4.16.0.0.MsalServiceException:
ErrorCode: federated_service_returned_error
Microsoft.Identity.Client.MsalServiceException: Federated service at <URL> returned error:
at Microsoft.Identity.Client.WsTrust.WsTrustWebRequestManager.GetWsTrustResponseAsync(WsTrustEndpoint wsTrustEndpoint, String wsTrustRequest, RequestContext requestContext)
at Microsoft.Identity.Client.WsTrust.CommonNonInteractiveHandler.GetWsTrustResponseAsync(UserAuthType userAuthType, String cloudAudienceUrn, WsTrustEndpoint endpoint, String username, SecureString securePassword)
StatusCode: 401
ResponseBody:
Headers: Date: Mon, 10 Aug 2020 20:24:54 GMT
Cache-Control: no-cache, no-store
Pragma: no-cache
WWW-Authenticate: Negotiate
Set-Cookie: PF=QSEPNWjNTF0s1lakkLKluT;Path=/;Secure;HttpOnly;SameSite=None
Transfer-Encoding: chunked
<---
Here is the simple code that I wrote:
app = PublicClientApplicationBuilder.Create(clientId).WithTenantId(tenant).WithAuthority(authority).Build();
try
{
Task<AuthenticationResult> result = app.AcquireTokenByIntegratedWindowsAuth(scopes).WithUsername(username).ExecuteAsync();
Console.Write(result.Result.AccessToken);
Console.ReadLine();
}
Just to further clarify, this works fine untill MSAL 4.15.0. It starts failing from the version MSAL 4.16.0 and above.
Any ideas why?