title: Basic Authentication using HTTP Commons Client
body: <p>I am looking at this link an am trying to send requests to the server</p>
  
  <p><a href="http://hc.apache.org/httpcomponents-client-ga/tutorial/html/authentication.html" rel="noreferrer">http://hc.apache.org/httpcomponents-client-ga/tutorial/html/authentication.html</a></p>
  
  <pre><code>public class Test {
      public static void main(String[] args) throws ClientProtocolException, IOException {
  
          DefaultHttpClient httpClient;
          URL url = new URL("https://9.5.127.34:443");
          httpClient = getSSLHttpClient(url);
          CredentialsProvider credsProvider = new BasicCredentialsProvider();
          credsProvider.setCredentials(
                  new AuthScope("https://9.5.127.34", AuthScope.ANY_PORT),
                  new UsernamePasswordCredentials("root", "passw0rd"));
  
  
           httpClient.setCredentialsProvider(credsProvider);
  
  
          HttpGet httpget = new HttpGet("https://9.5.127.34/powervc/openstack/volume/v1/115e4ad38aef463e8f99991baad1f809//volumes/3627400b-cd98-46c7-a7e2-ebce587a0b05/restricted_metadata");
          HttpResponse response = httpClient.execute(httpget);
          BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
          String line = "";
          while ((line = rd.readLine()) != null) {
  
              System.out.println(line);
  
              }   
          }
  </code></pre>
  
  <p>But it is giving me error as</p>
  
  <pre><code>Authentication required
  </code></pre>
  
  <p>Please tell me what I am doing wrongly. Thanx in Advance</p>