-
Notifications
You must be signed in to change notification settings - Fork 358
Open
Description
Hello,
I have been searching, but I have not been able to find how to use NTLM Authorization when using OData Connected Service DataServiceContext.
Only way I have found for now is to ConfigureHttpClientDefaults like this:
builder.Services.AddHttpClient();
builder.Services.ConfigureHttpClientDefaults(clientBuilder =>
{
clientBuilder.ConfigurePrimaryHttpMessageHandler(() =>
{
string domain = string.Empty;
string serviceUsername = ApplicationSettings.ServiceUsername;
string servicePassword = ApplicationSettings.ServicePassword;
if (serviceUsername.Contains('\\'))
{
var domainAndUser = serviceUsername.Split('\\');
domain = domainAndUser[0];
serviceUsername = domainAndUser[1];
}
HttpClientHandler handler = new HttpClientHandler();
handler.Credentials = new NetworkCredential(serviceUsername, servicePassword, domain);
return handler;
});
});
and then use the IHttpClientFactory with the DataServiceContext.
This works well, but my issue with it is that I have to configure the default HttpClients generated by the IHttpClientFactory to use NTLM Authorization, so now if I want to use a HttpClient without the NTLM Authorization, I have to use a named HttpClient. I think It would be more convenient if we were able to use named HttpClients with DataServiceContext.
Metadata
Metadata
Assignees
Labels
No labels