I am trying to access endpoints hosted on azure app services from excel add-in solution. I am using integrated windows authentication to generate an access token. Everything was working fine and I could access anthing I need from azure using the add-in but suddenly today when I am testing the add-in again, I am getting this exception: Microsoft.Identity.Client.MsalClientException: There was an error parsing WS-Trust response from the endpoint. This may occur if there is an issue with your ADFS configuration.
After debugging I found the the exception is raised from this code
IPublicClientApplication app = PublicClientApplicationBuilder.Create(configuration.ClientID)
.WithAuthority(new Uri(configuration.Authority))
.Build();
AcquireTokenByIntegratedWindowsAuthParameterBuilder authenticationResult = app.AcquireTokenByIntegratedWindowsAuth(new string[] { configuration.Audience });
configuration.AccessToken = await authenticationResult.ExecuteAsync();
On the other hand when I try to use the same library that acquire the access token from a console app, everything is working fine.
so what may block the excel add-in itself from acquiring the token.
2
Answers
For me the problem was related to the app service TLS version, it was configured to use TLS version 1.0 which is depricated. Changing the version to 1.2 solved the issue for me
You can get this error when using
AcquireTokenByIntegratedWindowsAuth
method .wrong credentials
(password) or if the user does not even exist .admin consents
are granted and 2FA is not enabled.The error code "parsing_wstrust_response_failed" can also may be due to configuration issues in the ADFS environment.
According to Integrated Windows Authentication · troubleshooting · GitHub
Some issues are:
Workaround
: Try upgrading the current .Net version or by using own HttpClient.Also wrong Service Principal Name(SPN) being logged due to misconfiguration or Allowing Channel Binding Token or Internet Explorer configuration can be other reasons for the cause of this error.
You can change Channel binding setting using PowerShell cmdlet
Set-ADFSProperties -ExtendedProtectionTokenCheck
Also make sure to check /enable Integrated Windows Authentication in Internet Explorer properties by going to Internet Options -> Advanced -> Security.
References: