Always getting com.rainmatter.kitehttp.exceptions.KiteTokenException

krtrader
Hi,

I am trying to establish connection using Kite Connect Library. But I always get below error:

com.rainmatter.kitehttp.exceptions.KiteTokenException
at com.rainmatter.kitehttp.KiteRequest.dealWithKiteException(KiteRequest.java:255)
at com.rainmatter.kitehttp.KiteRequest.postRequest(KiteRequest.java:51)
at com.rainmatter.kiteconnect.KiteConnect.requestAccessToken(KiteConnect.java:181)
at main.java.com.algotrading.api.zerodha.login.ZerodhaLogin.Login(ZerodhaLogin.java:28)
at main.java.com.algotrading.main.MainClass.main(MainClass.java:10)

My code is as below:
// Initialize Kiteconnect using apiKey.
KiteConnect kiteConnect = new KiteConnect(Constants.API_KEY);

// Set userId.
kiteConnect.setUserId(Constants.ZERODHA_ID);

// Get accessToken as follows,
UserModel userModel = null;
try {
userModel = kiteConnect.requestAccessToken(requestToken, Constants.API_SECRET);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}catch (KiteTokenException e)
{
e.printStackTrace();
}catch (KiteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

Note: I have already retrieved request token using Zerodha Login URL.
Sign In or Register to comment.