HttpClient & Windows Auth: Pass logged in User of Consumer to Service

后端 未结 3 748
我寻月下人不归
我寻月下人不归 2020-12-13 05:34

I am struggling to understand and set up a Service and Consumer where the Service will run as the user logged into the Consumer.

My consumer is an MVC application. M

3条回答
  •  情深已故
    2020-12-13 06:03

    If you are trying to access service which is hosted on windows authentication then do following.

    var request = new RestRequest(Method.POST);
    

    If you want to use applications default credentials which must have access on hosted service server

    request.UseDefaultCredentials = true;
    

    or user below to pass the credentials manually

    request.Credentials = new NetworkCredential("Username", "Password", "Domain");
    

提交回复
热议问题