RestSharp HttpBasicAuthentication - example

后端 未结 5 1479
梦毁少年i
梦毁少年i 2021-01-03 20:51

I have a WPF client using RestSharp and WEB API Service. I try to use HttpBasicAuthenticator as follows:

RestRequest login = new RestRequest(\"/         


        
5条回答
  •  悲哀的现实
    2021-01-03 21:27

    new SimpleAuthenticator("username", username, "password", password) did NOT work with me.

    The following however worked:

    var client = new RestClient("http://example.com");
    client.Authenticator = new HttpBasicAuthenticator(userName, password);
    
    var request = new RestRequest("resource", Method.GET);
    client.Execute(request);
    

提交回复
热议问题