I’m trying to calculate my signature for getting balance. Here is my java/logic pulled essentially right from the api documentation:

import java.io.*;
import java.nio.file.*;
import java.util.*;
import java.security.spec.*;
import javax.crypto.*;
import javax.xml.bind.*;

public String getHashedSecretKey(String nonce) throws Exception{

String endpoint = “/v1/account/balance”;
String secret = “abc123”;

//splice string for signing
String strForSign = endpoint + “/” + nonce + “/”;

//Make a base64 encoding of the completed string
String signatureStr = Base64.getEncoder().encodeToString(strForSign.getBytes(“UTF-8”));

Mac sha256_HMAC = Mac.getInstance(“HmacSHA256”);
SecretKeySpec secretKeySpec = new SecretKeySpec(secret.getBytes(“UTF-8”), “HmacSHA256”);
sha256_HMAC.init(secretKeySpec);

//Convert to hex
String signatureResult = DatatypeConverter.printHexBinary(sha256_HMAC.doFinal(signatureStr.getBytes(“UTF-8”)));

return signatureResult;

}

This is the command I’m executing in windows terminal through java:

String command = “curl -H “KC-API-KEY: ” + apiKey + “” -H “KC-API-NONCE: ” + nonce + “” -H “KC-API-SIGNATURE: ” + getHashedSecretKey(nonce) + “” -X GET “https://api.kucoin.com/v1/account/balance/””;

This is my output:

{“code”:”UNAUTH”,”msg”:”Signature verification failed”,”success”:false,”timestamp”:1547202915313}

Any help at all is tremendously appreciated, i am dying


➔ Visit Kucoin now and start trading

1 Comment

  1. CurrensKruptos on 12. January 2019 at 19:55

    Hi u/rat-butter! For further clarification regarding your concern, please contact our [online support](https://www.kucoin.com/zendesk_chat.html). Thank you.