1. Call this URL https://kite.trade/connect/login?api_key=myapikey 2. This redirect to my url something.com 3. I will get request token (This is working fine) 4. Now I invoke below method I get access token & public token (Suddenly stopped working)
public String login(String reqToken) {
try { // First you should get request_token, public_token using kitconnect login and // then use request_token, public_token, api_secret to make any kiteConnect api // call. // Initialize KiteSdk with your apiKey.
KiteConnect kiteConnect = new KiteConnect("myapisecret");
// set userId kiteConnect.setUserId("myzerodhaid");
// Set session expiry callback. kiteConnect.registerHook(new SessionExpiryHook() { @Override public void sessionExpired() { System.out.println("session expired"); } });
// Set request token and public token which are obtained from login process. UserModel userModel = kiteConnect.requestAccessToken(reqToken, "myapisecret");
You seem to be using old Kite Connect API. You are setting api_secret in place of api_key. You seem to be setting public token instead of the access token. Are you sure this was working earlier?
This is how I implemented:
1. Call this URL https://kite.trade/connect/login?api_key=myapikey
2. This redirect to my url something.com
3. I will get request token (This is working fine)
4. Now I invoke below method I get access token & public token (Suddenly stopped working)
public String login(String reqToken) {
try {
// First you should get request_token, public_token using kitconnect login and
// then use request_token, public_token, api_secret to make any kiteConnect api
// call.
// Initialize KiteSdk with your apiKey.
KiteConnect kiteConnect = new KiteConnect("myapisecret");
// set userId
kiteConnect.setUserId("myzerodhaid");
// Set session expiry callback.
kiteConnect.registerHook(new SessionExpiryHook() {
@Override
public void sessionExpired() {
System.out.println("session expired");
}
});
// Set request token and public token which are obtained from login process.
UserModel userModel = kiteConnect.requestAccessToken(reqToken, "myapisecret");
kiteConnect.setAccessToken(userModel.accessToken);
kiteConnect.setAccessToken(userModel.publicToken);
return "success";
} catch (KiteException e) {
System.out.println(e.message + " " + e.code + " " + e.getClass().getName());
}
return "";
}
Are you sure this was working earlier?
Please update the example given in this page. It is still showing old way of login using public token etc..
https://github.com/zerodhatech/javakiteconnect/tree/kite3