Unable to get the login response.

Jagadish
Hi Team,

I've created a developer app & got the keys,
Here is my api_key = dubkopw3dv1i5006

Am getting the app login page when i entered my credentials i have been redirected.

In the redirected page i generated sha-256 with(api_key+request_token+secret_key) & sent a post request to obtain access_token but the response i received is 403

I've also tried it by sending (api_key+request_token+secret_key)keys to java microservice & from there I've generated byte, made a post call. but doesn't work I've received "Server returned HTTP response code: 400 for URL: https://api.kite.trade/session/token".

when i made a post call from rest client I got an error message like this
{
"status": "error"
"message": "Invalid session credentials"
"error_type": "TokenException"
}


could anyone please guide me.

Quick Response is appreciated!

Thanks
  • Kailash
    @Jagadish 400 implies you are not sending the required params. Please share the POST variables you are sending.
  • Jagadish
    @Kailash thanks for the reply

    Sorry I was actually facing 403
    my POST code is like this
    String url = "https://api.kite.trade/session/token";
    URL obj = new URL(url);
    HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
    String checksum = getSHA256Hash(Object.getString("api_key")+Object.getString("request_token")+Object.getString("secret_Key"));
    System.out.println("checksum:"+checksum);
    String UrlParamter = "api_key="+Object.getString("api_key")+"&request_token="+Object.getString("request_token")+"&checksum="+checksum;
    OutputStreamWriter wr = new OutputStreamWriter(con.getOutputStream());
    wr.write(UrlParamter);
    wr.flush();
    wr.close();
    int responseCode = con.getResponseCode();
    System.out.println("Response Code : " + responseCode);

    BufferedReader in = new BufferedReader(
    new InputStreamReader(con.getInputStream()));
    String inputLine;
    StringBuffer response1 = new StringBuffer();

    while ((inputLine = in.readLine()) != null) {
    response1.append(inputLine);
    }
    in.close();
    //print result
    System.out.println(response1.toString());
    return response1.toString();
    the method which generates sha-256 is:
    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;
    }
    the error which am getting is:


    Response Code : 403
    Server returned HTTP response code: 403 for URL: https://api.kite.trade/session/token
  • Kailash
    Object.getString("secret_Key")

    Is `Key` meant to be sentence cased? This error happens if either of the 3 parameters you pass are incorrect.
  • Jagadish
    Jagadish edited August 2016
    @Kailash thanks again i have noticed that i created a publisher app but am suppose to create a connect type app now authenticated my zerodha account, also transfered credits, i can see the status of my newly created app is pending clue less about when it gets activated.
  • Vivek
    @Jagadish Seems like some issues while creating app. Please click on the app and activate it. The action will debit 2000 credits from your account and app will be activated instantly.
Sign In or Register to comment.