title: Android HttpClient authentication always returns 401 code
body: <p>I'm trying to post the player score on-line using HTTP authentication but the response is always 401 (Unauthorized), although I'm pretty sure the username and password is correct. What am I doing wrong?</p>
  
  <pre><code>DefaultHttpClient client = new DefaultHttpClient();
  Credentials creds = new UsernamePasswordCredentials("user", "passsword");
  client.getCredentialsProvider().setCredentials(new AuthScope("http://myurl.com/score.php", 80), creds);
  
  try {
      HttpPost post = new HttpPost("http://myurl.com/score.php");
  
      List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(3);   
      nameValuePairs.add(new BasicNameValuePair("score", points));
      nameValuePairs.add(new BasicNameValuePair("name", name));
      post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
      HttpResponse response = client.execute(post);
      final int statusCode = response.getStatusLine().getStatusCode();
      if (statusCode != HttpStatus.SC_OK) {
          throw new Exception();
      }
  
  } catch (UnsupportedEncodingException e) {
      //
  } catch (IOException e) {
      //
  } catch (Exception e) {
      //
  }
  </code></pre>
  
  <p>What's wrong with my code?</p>