This discussion is archived
7 Replies Latest reply: Feb 19, 2013 12:37 AM by 990745 RSS

Getting a Proxy Authentication error with HTMLUnit

990745 Newbie
Currently Being Moderated

I am using HTML Unit to automate a Google Search. I am using the proxy server of my organisation. The following lines of code

final WebClient webClient = new WebClient(BrowserVersion.FIREFOX_10, "", 80);

     //set proxy username and password
     final DefaultCredentialsProvider credentialsProvider = (DefaultCredentialsProvider) webClient.getCredentialsProvider();
     credentialsProvider.addCredentials("mysusername", "mypassword");

     final HtmlPage page = webClient.getPage("");


gives me the error "407 Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied. ) for". I am supplying my username and password to the defaultCredentialsProvider. I also tried setting System property for proxyPort and ProxyHost as follows


but I guess HTMLUnit uses httpclient internally for authentication which ignores the JVM flags. Can anybody give me some pointers on the solution.


  • Correct Answers - 10 points
  • Helpful Answers - 5 points