title: Volley throwing AuthFailureError (401) with Basic HTTP Authentication
body: <p>I'm trying to make a GET request in an Android application using the Volley library. This GET request is to verify account credentials using Basic HTTP Authentication. I verified the URL with credentials works in my browser as it returns successful XML. The format is: </p>
  
  <p><code>http://username:password@myanimelist.net/api/account/verify_credentials.xml</code></p>
  
  <p>where <code>username</code> and <code>password</code> obviously represent real user credentials. Volley throws this error:</p>
  
  <pre><code> BasicNetwork.performRequest: Unexpected response code 401 for http://username:password@myanimelist.net/api/account/verify_credentials.xml
  </code></pre>
  
  <p>Here is my Android code that handles the request:</p>
  
  <pre><code>private static final String HTTP_PRE = "http://";
  private static final String VERIFY_CREDENTIALS = "myanimelist.net/api/account/verify_credentials.xml";
  
  public void verifyCredentials(String username, String password) {
      RequestQueue queue = Volley.newRequestQueue(context);
      String url = HTTP_PRE + username + ":" + password + "@" + VERIFY_CREDENTIALS;
  
      StringRequest stringRequest = new StringRequest(Request.Method.GET, url, new Response.Listener&lt;String&gt;() {
  
          @Override
          public void onResponse(String response) {
              processResponse(response);
          }
      }, new Response.ErrorListener() {
  
          @Override
          public void onErrorResponse(VolleyError error) {
              // handle error
              Log.d(TAG, "error: " + error.getMessage());
          }
      });
  
      queue.add(stringRequest);
  }
  </code></pre>
  
  <p>This solution to override the getHeaders() method provided the same result:
  <a href="https://stackoverflow.com/questions/16817980/how-does-one-use-basic-authentication-with-volley-on-android">How does one use Basic Authentication with Volley on Android?</a>.</p>
  
  <p>Here is my implementation of that solution:</p>
  
  <pre><code>@Override
  public Map&lt;String, String&gt; getHeaders() throws AuthFailureError {
      Map&lt;String, String&gt; params = super.getHeaders();
      if (params == null){
          params = new HashMap&lt;&gt;();
      }
      String creds = String.format("%s:%s", username, password);
  
      params.put("Authorization", creds);
  
      return params;
  }
  </code></pre>
  
  <p>Which returned this error without the credentials built directly into the URL:</p>
  
  <pre><code>BasicNetwork.performRequest: Unexpected response code 401 for http://myanimelist.net/api/account/verify_credentials.xml
  </code></pre>
  
  <p>If someone could provide advice, I'd really appreciate it. This is my first time using Basic HTTP Authentication so I could be missing something obvious.</p>