Invalid checksum

yar.srikanth
Hi im getting below error

{"status": "error", "message": "Invalid checksum", "error_type": "TokenException"}



below is my code in C#


Byte[] byteArray = Encoding.UTF8.GetBytes(api_key + request_token + api_secret);

SHA256 myHash = SHA256Managed.Create();
Byte[] hashedByteArray = myHash. ComputeHash(byteArray);
string checksumString = Encoding.UTF8.GetString(hashedByteArray);

var httpClient = new HttpClient();
httpClient.BaseAddress = new Uri("https://api.kite.trade/");

StringContent data = new StringContent("api_key="+ api_key+ "&request_token="+ request_token + "&checksum="+ checksumString);
var responseMessage = httpClient.PostAsync("session/token", data).Result;

var result = responseMessage.Content.ReadAsStringAsync().Result;



my api key is 4xzr5o38b5pv8e4n


  • Kailash
    There's something wrong with the SHA-256 hash you are creating then.

    Generate a request token, and PM me the request_token and the hash you are generating. I'll check if your hash matches the right one.
  • yar.srikanth
    yea i fixed it. i made this change

    Byte[] byteArray = Encoding.UTF8.GetBytes(api_key + request_token + api_secret);

    SHA256 myHash = SHA256Managed.Create();
    Byte[] hashedByteArray = myHash.ComputeHash(byteArray);
    StringBuilder Sb = new StringBuilder();
    foreach (Byte b in hashedByteArray)
    Sb.Append(b.ToString("x2"));

    //string checksumString = Encoding.UTF8.GetString(hashedByteArray);

    string checksumString = Sb.ToString();
This discussion has been closed.