Unable to get access token in Java

vaishakh
Hi,
In Java, we are trying to get the access token, but getting an error: {"status": "error", "message": "Invalid checksum", "error_type": "TokenException"}

Below is the code snippet we are using:
public void getAccessToken(String requestToken,String apiKey, String secretKey) {
PostMethod postMethod = null;
try {
postMethod = new PostMethod("https://api.kite.trade/session/token");
postMethod.addParameter("api_key", apiKey);
postMethod.addParameter("request_token", requestToken);
postMethod.addParameter("checksum", getSHA256Hash(apiKey+requestToken+secretKey));
HttpClient client = new HttpClient();
int httpStatusCode = client.executeMethod(postMethod);
System.out.println("HTTPStatusCode [" + httpStatusCode + "] [" + postMethod.getResponseBodyAsString() + "]");
} catch (Exception e) {
e.printStackTrace();
} finally {
if (postMethod != null) {
postMethod.releaseConnection();
}
}
}

private String getSHA256Hash(String data) {
String result = null;
try {
MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] hash = digest.digest(data.getBytes(StandardCharsets.UTF_8));
// return String.valueOf(hash);
return DatatypeConverter.printHexBinary(hash); // make it printable
}catch(Exception ex) {
ex.printStackTrace();
}
return result;
}
Validated the checksum value on http://www.xorbin.com/tools/sha256-hash-calculator and it's matching with the checksum value generated by getSHA256Hash() method. Please can you help us to resolve this issue?

Regards,
Vaishakh
This discussion has been closed.