a)Were will I get the Request Token and Secret Key to generate a Session for the below? User user = kiteSdk.generateSession("request_token", "your_apiSecret");
You need to have an active KiteConnect subscription to use KiteConnect APIs . You can't use KiteConnect with Kite Publisher App which only has Api_key .
I have an active account, but I managed now but taking the request token after manually login and using in my program before it expires. But how can I ensure I dont need do this manually?
I got the Access Token from below code: User user = kiteConnect.generateSession("asasa", "asasa"); kiteConnect.setAccessToken(user.accessToken); kiteConnect.setPublicToken(user.publicToken);
As per comments is stating that This access Token is valid valid for whole day right? But I have below observations: 1. KiteConnect kiteConnect = new KiteConnect("ssasasa"); kiteConnect.setUserId("XX3700"); String url = kiteConnect.getLoginURL();
kiteConnect.setSessionExpiryHook((SessionExpiryHook) new SessionExpiryHook() { @Override public void sessionExpired() { System.out.println("session expired"); } }); // Request Token, API Secret User user = kiteConnect.generateSession("sasa", "sasa"); kiteConnect.setAccessToken(user.accessToken); kiteConnect.setPublicToken(user.publicToken);
If we execute this code snippet the Java Process continues runs and never stopped.
2. Can we use this access token for full day trade activities in other session? 3. If we stopped the process at point 1, the Access token still valid? 4. If we logged out and from point 1, can we still use the stored access token for other API call?
The code snippet in sample code is for reference and it shouldn't be used as is without understanding.
An app can only have one active access token at any point in time. An access token once generated can be used for whole day.
Stopping a process will not invalidate access token unless delete access token is called explicitly or access token will be cleared everyday morning after BOD is run.
No, if you logout in one place, you are logged out everywhere.
https://developers.kite.trade/
You can understand login flow here:
https://kite.trade/docs/connect/v3/user/
b) It's the response you get by calling generate session method.
https://github.com/zerodha/javakiteconnect/blob/b0e847eb7feae617bafd1fc95a95dde559298722/sample/src/Test.java#L48
https://kite.trade/docs/connect/v3/user/#authentication-and-token-exchange
kiteSdk.generateSession(REQ_TOKEN_VALUE, API_SECRET);
but it is giving Token Exception.
Regards,
Naveen
https://kite.trade/forum/discussion/11445/string-url-kitesdk-getloginurl#latest
You need to have an active KiteConnect subscription to use KiteConnect APIs . You can't use KiteConnect with Kite Publisher App which only has Api_key .
So, automatic login is not possible.
A request token is valid for almost 5 minutes,use it immediately to get access token.
I got the Access Token from below code:
User user = kiteConnect.generateSession("asasa", "asasa");
kiteConnect.setAccessToken(user.accessToken);
kiteConnect.setPublicToken(user.publicToken);
As per comments is stating that This access Token is valid valid for whole day right?
But I have below observations:
1.
KiteConnect kiteConnect = new KiteConnect("ssasasa");
kiteConnect.setUserId("XX3700");
String url = kiteConnect.getLoginURL();
kiteConnect.setSessionExpiryHook((SessionExpiryHook) new SessionExpiryHook() {
@Override
public void sessionExpired() {
System.out.println("session expired");
}
});
// Request Token, API Secret
User user = kiteConnect.generateSession("sasa", "sasa");
kiteConnect.setAccessToken(user.accessToken);
kiteConnect.setPublicToken(user.publicToken);
If we execute this code snippet the Java Process continues runs and never stopped.
2. Can we use this access token for full day trade activities in other session?
3. If we stopped the process at point 1, the Access token still valid?
4. If we logged out and from point 1, can we still use the stored access token for other API call?
An app can only have one active access token at any point in time. An access token once generated can be used for whole day.
Stopping a process will not invalidate access token unless delete access token is called explicitly or access token will be cleared everyday morning after BOD is run.
No, if you logout in one place, you are logged out everywhere.