title: Coinbase API authentication always invalid signature with Java
body: <p>I've been trying to authenticate myself at the Coinbase API with Java. I've been looking for my mistake for a few days now but can't find it. I always receive an Invalid Signature mistake. My method for creating a signature looks like this:</p>
  <pre><code>public static String createSignature(String secret, String time, String method,String uri, String body) throws URISyntaxException, JSONException {
      String keyspec = org.apache.commons.codec.digest.DigestUtils.sha256Hex(secret);
      System.out.println(&quot;Keyspec: &quot; + keyspec);
      String prehash = time + method.toUpperCase() + uri + body;
      String sign = Base64.getEncoder().encodeToString(org.apache.commons.codec.digest.DigestUtils.sha256(prehash.getBytes()));
      System.out.println(&quot;Signature: &quot; + sign);
      return sign;
  }
  </code></pre>
  <p>I call the method like this:</p>
  <pre><code>String path = &quot;https://api.coinbase.com/v2/user&quot;;
  HttpRequest request = HttpRequest.newBuilder()
              .uri(new URI(path))
              .headers(&quot;CB-ACCESS-KEY&quot;,&quot;my_access_key&quot;,&quot;CB-ACCESS-SIGN&quot;,createSignature(&quot;my_secret_key&quot;, path, &quot;GET&quot;,currTime,&quot;&quot;),&quot;CB-ACCESS-TIMESTAMP&quot;,currTime)
              .GET()
              .build();
  </code></pre>
  <p>I also get the current epoch time from the Coinbase API so a difference between the time of my PC and the server shouldn't be the case.
  Thank you in advance!</p>