title: HttpClient 4.2, Basic Authentication, and AuthScope
body: <p>I have an application connecting to sites that require basic authentication. The sites are provided at run time and not known at compile time.</p>
  
  <p>I am using HttpClient 4.2.</p>
  
  <p>I am not sure if the code below is how I am supposed to specify basic authentication, but the documentation would suggest it is. However, I don't know what to pass in the constructor of <code>AuthScope</code>. I had thought that a null parameter meant that the credentials supplied should be used for all URLs, but it throws a <code>NullPointerException</code>, so clearly I am wrong.</p>
  
  <pre><code>m_client = new DefaultHttpClient();
  UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(m_userName, m_password);
  ((DefaultHttpClient)m_client).getCredentialsProvider().setCredentials(new AuthScope((HttpHost)null), credentials);
  </code></pre>