Connect to API via JWT (Quoine)

I am trying to connect to the Quoine API. They are using JSON Web Token and describe the API access here:

I am using io.jsonwebtoken for JWT to sign the payload


My code looks like this:

public void connect(){
    String nonce = String.valueOf(new Date().getTime());

    String connectionString = "";
    JSONObject payLoad = new JSONObject();

    payLoad.put("path", command);
    payLoad.put("nonce", nonce);
    payLoad.put("token_id", "my key");

    String payLoadAsString = payLoad.toJSONString();

    CloseableHttpClient httpClient = HttpClients.createDefault();
    HttpPost post = new HttpPost(connectionString);

    String compactJws = Jwts.builder()
              .signWith(SignatureAlgorithm.HS256, "my secret")

    List<NameValuePair> params = new ArrayList<>();
    params.add(new BasicNameValuePair("X-Quoine-API-Version", "2"));
    params.add(new BasicNameValuePair("X-Quoine-Aut", compactJws));
    params.add(new BasicNameValuePair("Content-Type", "application/json"));

    CloseableHttpResponse response = null;
        post.setEntity(new UrlEncodedFormEntity(params));
        response = httpClient.execute(post);
    }catch(Exception e){



But I always get an 302 Moved Temporarily error:

HttpResponseProxy{HTTP/1.1 302 Moved Temporarily [Date: Thu, 12 Oct 2017 22:47:39 GMT, Transfer-Encoding: chunked, Connection: keep-alive, Cache-Control: private, max-age=0, no-store, no-cache, must-revalidate, post-check=0, pre-check=0, Expires: Thu, 01 Jan 1970 00:00:01 GMT, Location:, Server: cloudflare-nginx, CF-RAY: 3acd9a295ab715d7-FRA] ResponseEntityProxy{[Chunked: true]}}

Is there something wrong with the implementation?