Always getting com.rainmatter.kitehttp.exceptions.KiteTokenException

keshavshetty
I just registred for kite connect and using java to build basic client to experiement.
However I always get KiteTokenException

My code as below

KiteConnect kiteconnect = new KiteConnect(CONSTANTS.API_KEY);

// set userId
kiteconnect.setUserId(CONSTANTS.USER_ID);

// Get login url
String url = kiteconnect.getLoginUrl();
UserModel userModel = kiteconnect.requestAccessToken("request_token", CONSTANTS.SECRET_KEY);

kiteconnect.setAccessToken(userModel.accessToken);
kiteconnect.setPublicToken(userModel.publicToken);
  • keshavshetty
    From browser using login url I see below message
    error_type "ForbiddenError"
    message "The user is not enabled on the app."
    status "error"

    What next? Contact customer care?
  • sujith
    Hi @keshavshetty,
    Are you sure you are using Kite Connect api_key?
    Don't use Kite Publisher's api_key.
  • sujith
    @keshavshetty,
    A request token is valid for a couple of minutes and validity is once. The access token is valid for one day.
    Once you get access token store it and reuse it, don't call requestAccessToken API for every run.
  • keshavshetty
    Hi Sujith,

    I am using Kite connect API (Not Publisher)
    I was not able to login even once and you say store access token !!!

    As per browser url, it is clear that

    error_type "ForbiddenError"
    message "The user is not enabled on the app."
    status "error"

    Something need to be enabled in the server side
  • keshavshetty
    Thanks Sujith,
    It resolved the issue. (I was not populating the request token)

    One more question, Everytime we have to use browser to get the request token? (Can we automate that also? (I tried with HttpClient, but didn't work)
  • sujith
    Hi @keshavshetty,
    It is mandatory by the exchange that a trader has to log in at least once a day.
    We don't recommend automating login.
This discussion has been closed.