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

五迷三道 提交于 2019-12-11 10:24:09

问题


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?


回答1:


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);


来源:https://stackoverflow.com/questions/34277041/windows-credentials-not-passing-through-using-windows-web-http-httpclient

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!