Sinaesthetic
Sinaesthetic

Reputation: 12192

Windows credentials not passing through using Windows.Web.Http.HttpClient

My app is trying to make a request to a service on our domain, but it's failing to pass through, the windows credentials of the user running the app which is causing a login request for every service call (there are several in a row... ultra-annoying)

If I set the ServerCredential to a PasswordCredential (using HttpBaseProtocolFilter) and use hardcoded information (resource, username, password) then everything works fine, but that is not adequate as it needs to be able to pass through the creds of whatever user is using the application.

Example:

var filter = new HttpBaseProtocolFilter
{
    ServerCredential = new PasswordCredential("ourServiceHost", "username", "password")
});

var client = new HttpClient(filter);

I read somewhere that not setting the ServerCredential should cause it to default to the current user's windows credentials, but that doesn't seem to be happening.

Ideas?

Upvotes: 1

Views: 505

Answers (1)

kiewic
kiewic

Reputation: 16420

You need to select the Enterprise Authentication capability in the Package.AppxManifest of your app.

To avoid the username and password prompt, disable the UI:

HttpBaseProtocolFilter filter = new BaseProtocolFilter();
filter.AllowUI = false;
HttpClient client = new HttpClient(filter);

Upvotes: 2

Related Questions