<p>Ok, it seems that for some reason I didn't read this essential part:</p>

<blockquote>
  <p>The easiest way to tell Java to use HTTP Basic authentication is to set a default Authenticator:</p>
</blockquote>

<pre><code>    final String rpcuser ="...";
  final String rpcpassword ="...";

  Authenticator.setDefault(new Authenticator() {
      protected PasswordAuthentication getPasswordAuthentication() {
          return new PasswordAuthentication (rpcuser, rpcpassword.toCharArray());
      }
  });
</code></pre>

CC BY-SA 3.0
2014-02-16T09:01:46.360Z
2014-02-16T09:01:46.360Z
pelican_george
<p>I'm trying to connect to a local dogecoin server with jsonRPC.</p>

<p>The dogecoin daemon is launched with the following parameters:</p>

<pre><code>dogecoin-qt -server -testnet -gen -debug -debugnet -printtoconsole -rpcuser=user -rpcpassword=user
</code></pre>

<p>The following Java code is used to connect to the server:</p>

<p>I'm using com.googlecode.jsonrpc4j.JsonRpcHttpClient</p>

<pre><code>            JsonRpcHttpClient client = new JsonRpcHttpClient(new URL("http://user:user@localhost:22555"));

        String response = "";
        client.invoke("getinfo()", response);
        System.out.println(response);
</code></pre>

<p>It just won't accept any credentials at all, I've tried setting them on the conf file, command-line, etc.</p>

<pre><code>Server returned HTTP response code: 401 for URL: http://user:user@localhost:22555
</code></pre>

<p>Any ideas ?</p>

CC BY-SA 3.0
2014-02-15T21:33:27.587Z
So... does it work now or what?
Jori
CC BY-SA 3.0
2014-02-15T22:26:01.457Z
The authentication part yes. (I cannot answer it myself within 8 hours). However you should take a look at this post http://bitcoin.stackexchange.com/questions/7528/bitcoind-returning-invalid-json-rpc-2-0-response?rq=1
pelican_george
<bitcoind><json-rpc><dogecoin>
Bitcoin/Dogecoin Daemon RPC authentication - 401 status error
pelican_george
# Bitcoin/Dogecoin Daemon RPC authentication - 401 status error

(Asked by: username_0 on 2014-02-15)

I'm trying to connect to a local dogecoin server with jsonRPC.

The dogecoin daemon is launched with the following parameters:

```
dogecoin-qt -server -testnet -gen -debug -debugnet -printtoconsole -rpcuser=user -rpcpassword=user

```

The following Java code is used to connect to the server:

I'm using com.googlecode.jsonrpc4j.JsonRpcHttpClient

```
            JsonRpcHttpClient client = new JsonRpcHttpClient(new URL("http://user:user@localhost:22555"));

        String response = "";
        client.invoke("getinfo()", response);
        System.out.println(response);

```

It just won't accept any credentials at all, I've tried setting them on the conf file, command-line, etc.

```
Server returned HTTP response code: 401 for URL: http://user:user@localhost:22555

```

Any ideas ?

**Tags:** bitcoind, json-rpc, dogecoin

> **Comments:**
> **username_1**: So... does it work now or what?  
> **username_0**: The authentication part yes. (I cannot answer it myself within 8 hours). However you should take a look at this post http://bitcoin.stackexchange.com/questions/7528/bitcoind-returning-invalid-json-rpc-2-0-response?rq=1  

---

## 1 answers

### Answer by username_0 on 2014-02-16. Score: 1

Ok, it seems that for some reason I didn't read this essential part:

> The easiest way to tell Java to use HTTP Basic authentication is to set a default Authenticator:

```
    final String rpcuser ="...";
  final String rpcpassword ="...";

  Authenticator.setDefault(new Authenticator() {
      protected PasswordAuthentication getPasswordAuthentication() {
          return new PasswordAuthentication (rpcuser, rpcpassword.toCharArray());
      }
  });

```


---

