Token expired immediately after creating it.

kris123
Hi,
I created a new app and attempted to login to my account.
I was able to generate the access token, and when i use it immediately, it still says token invalid and expired.

User id: VH7775

Error in console
INFO: server: cloudflare
Mar 09, 2023 2:39:35 PM okhttp3.internal.platform.Platform log
INFO: cf-ray: 7a522e052f432e9c-HYD
Mar 09, 2023 2:39:35 PM okhttp3.internal.platform.Platform log
INFO: alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400
Mar 09, 2023 2:39:35 PM okhttp3.internal.platform.Platform log
INFO:
Mar 09, 2023 2:39:35 PM okhttp3.internal.platform.Platform log
INFO: {"status":"error","message":"Token is invalid or has expired.","data":null,"error_type":"TokenException"}
Mar 09, 2023 2:39:35 PM okhttp3.internal.platform.Platform log
INFO: Code
The error is being raised at the "GenerateSession" invocation.

KiteConnect kiteConnect = new KiteConnect(apiKey, true);
kiteConnect.setUserId(userId);
// Get login URL
String url = kiteConnect.getLoginURL();

try {
User user = kiteConnect.generateSession(sessionId, apiSec);

kiteConnect.setAccessToken(user.accessToken);
kiteConnect.setPublicToken(user.publicToken);
}
catch(Exception e) {
e.printStackTrace();
}

Profile profile = kiteConnect.getProfile();
System.out.println("Zerodha Login : " + profile.userName);

Tagged:
  • rakeshr
    Token is invalid or has expired.
    Go through the login FAQs here.
  • kris123
    I have read the faq's and login page documentation mutliple times, but still missing why such logouts are happening. Hence i have posted a discussion. Please do not redirect to the same login page documentation. Thank you.
  • kris123
    If possible, could someone post a sample code,
    wherein they hit the historical API for different instruments in a For Loop, which should be hardly around 10-15 lines. Thank you.
This discussion has been closed.