title: Authentication not working jsonrpc2 library
body: <p>I keep getting 401 error when trying to access an api, the api requires a username and password which i have given. I'm using jsonrpc2 library to make this all work. Here is my code:</p>
  
  <p>App.java</p>
  
  <pre><code> public class App {
  
  public static JSONRPC2Session rpcSession;
  private static final String MONERO_URL = "http://localhost:18082/json_rpc";
  public static int requestId = 1;
  public static JSONRPC2Request request;
  public static JSONRPC2Response response;
  
  public static void main(String[] args) throws MalformedURLException, JSONRPC2SessionException
  {
    MoneroClient client = new MoneroClient(MONERO_URL); 
    client.getBalance();
  
  }
  }
  </code></pre>
  
  <p>MoneroClient.java</p>
  
  <pre><code>public class MoneroClient {
  
  private int requestId = 0;
  
  private JSONRPC2Session rpcSession;
  
  public MoneroClient(String url) throws MalformedURLException {
      rpcSession = new JSONRPC2Session(new URL(url));
  
      rpcSession.setRawResponseInspector(new MyInspector());
  
  
      rpcSession.setConnectionConfigurator(new BasicAuthenticator());
  } 
  public BigDecimal getBalance() throws JSONRPC2SessionException {
      BigDecimal balance = null;
      JSONObject result = rpcCall("getbalance", null);
      if (result != null) {
          balance = BigDecimal.valueOf(Long.valueOf("" + result.get("balance")), 12);
          //balance = String.valueOf(result.get("balance"));
      }
      return balance;
  }
  
  private JSONObject rpcCall(String method, List&lt;Object&gt; params) throws JSONRPC2SessionException {
      JSONRPC2Request request = new JSONRPC2Request(method, params, ++requestId);
      JSONRPC2Response response = rpcSession.send(request);
      JSONObject result = null;
      if (response.indicatesSuccess()) {
          result = (JSONObject) response.getResult();
      } else {
          // TODO: Throw exception
          System.err.println(response.getError().getMessage());
      }
      return result;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>BasicAuthenicator.java</p>
  
  <pre><code>public class BasicAuthenticator implements ConnectionConfigurator
  {
  
      public void configure(HttpURLConnection connection) 
      {
          connection.addRequestProperty("Authorization", "Basic QWxhZGRpbjpPcGVuU2VzYW1l");
      }
  }
  </code></pre>