Getting KiteTokenException repeatedly with message 'Invalid session credentials'

ZD4873
My UserId is ZD4873 and I am exactly following the steps given on:

https://github.com/rainmattertech/javakiteconnect

i.e.

// Initialize Kiteconnect using apiKey.
Kiteconnect kiteSdk = new Kiteconnect("my_apiKey");

// Set userId.
kiteSdk.setUserId("ZD4873);

//Get the URL
String url = kiteSdk.getLoginUrl();

I paste this Url in my web browser and post authentication I get this link

https://kite.trade/?status=success&request_token=aiuryuiib8obe6n4dv9l8m3ffkccd6hu

I then

// Get accessToken as follows,
UserModel userModel = kiteSdk.requestAccessToken("aiuryuiib8obe6n4dv9l8m3ffkccd6hu", "my_apiSecret");


I always get KiteTokenException with message 'Invalid session credentials'

Please help
  • sujith
    Hi,
    A request token is valid for only one time and will expire in a couple of minutes.
    An access token is valid for one whole day. So, once you get access token store it in preference or database and reuse it in next run till it expires.
    Don't call requestAccessToken every time you run the app.
  • ZD4873
    Hi Sujith,

    Thanks for the info

    But the very first call to requestAccessToken gets failed with the exception. I haven't yet got the access token
  • sujith
    It has the complete login flow.
  • ZD4873
    This is exactly what I am doing in my Java code. However, I haven't went past requestAccessToken call due to the said exception
  • sujith
    Are you sure you are using it in a couple of minutes and only once?
    We use the same code for testing. It is working fine.
  • abhash2610
    @ZD4873 , even I'm using the java api and it is working as expected. Are you using publisher api or full connect api?
  • ZD4873
    Hi @abhash2610,

    I am using the full connect api.

    Hi @sujith
    I tried again today with the request_token=amlm099pitsy1s2ohjyon9wuq8vne0dh

    and again the same result :(, raised a support ticket, lets see
  • sujith
    Hi,
    Support executives probably don't know the technicalities of Kite Connect.
    Can you make a video of the steps you are doing and private message me?
  • ZD4873
    Works fine now @sujith , didn't change anything on my side but now it works like charm
This discussion has been closed.