I am writing a console application which uses SSO (Windows Authentication) for login into a third party web API. The code works with .NET Framework 4.6.1, but not with .NET Core 3.1.
During the tests I reduced the problem to the request to get the token from the identity provider and created two application, one with .NET Framework 4.6.1 and one with .NET Core 3.1 with exact the same code in Main:
string uri = "http://<server>/connection/single-sign-on/identity-providers/90c22f9b-0a9d-4474-87f4-b48eccbe3095?singleSignOnCapabilities=saml2Redirect";
try {
using (HttpClient client = new HttpClient(new HttpClientHandler() { UseDefaultCredentials = true })) {
var response = client.GetAsync(uri).Result;
Console.WriteLine(response.StatusCode);
if (response.IsSuccessStatusCode) {
// Get token from response header
// This works with .NET 4.6.1
}
}
}
catch {
// In .NET Core 3.1 I get an exception: The remote server returned an error: (401) Unauthorized.
}
Because of the comment from Camilo Terevinto, I changed the example to HttpClient with the same result.
Btw: Can experience the same behaviour with Windows Powershell and Powershell Core. It seems to be a general different implementation on Framework and Core.