Hi I am receiving "Session Expired" while trying to connect. here is the code i have used
public void connectToKite() throws JSONException, IOException, KiteException { // Connect to Kite kiteConnect = new KiteConnect(apiKey); // Set userId kiteConnect.setUserId("DM1881"); // Enable logs for debugging purpose. This will log request and // response. // kiteConnect.setEnableLogging(true);
// Get login url url = kiteConnect.getLoginURL(); // Set session expiry callback. kiteConnect.setSessionExpiryHook(new SessionExpiryHook() { @Override public void sessionExpired() { System.out.println("session expired"); } });
user = kiteConnect.generateSession(requestKey, apiSecret); kiteConnect.setAccessToken(user.accessToken); kiteConnect.setPublicToken(user.publicToken); }
I am requesting request token and updating it before calling this method. Please let me know what is wrong with this code.
Exception in thread "main" session expired com.zerodhatech.kiteconnect.kitehttp.exceptions.TokenException at com.zerodhatech.kiteconnect.kitehttp.KiteResponseHandler.dealWithException(KiteResponseHandler.java:48) at com.zerodhatech.kiteconnect.kitehttp.KiteResponseHandler.handle(KiteResponseHandler.java:20) at com.zerodhatech.kiteconnect.kitehttp.KiteRequestHandler.postRequest(KiteRequestHandler.java:85) at com.zerodhatech.kiteconnect.KiteConnect.generateSession(KiteConnect.java:180) at mp.trade.app.ThirdCandle.connectToKite(ThirdCandle.java:294) at mp.trade.app.ThirdCandle.Trade(ThirdCandle.java:102) at mp.trade.app.ThirdCandle.main(ThirdCandle.java:91)