How to maintain Refersh Token and Access token programmatically in python

V2R
I am creating application with kite. I have observed that we need to create access token everyday. Till now I am manually login in to the application and create the request token and then create a access token from that.

But now I want this thing to be done programmatically in python.

(I am using Django Framework for accessing this python client)
  • sujith
    You can check out this thread.
  • V2R
    @sujith I have tried this like:

    kite = KiteConnect(api_key=KITE_API_KEY)
    data = kite.renew_access_token(KITE_REFRESH_TOKEN, KITE_API_SECRET)
    print(data)

    But it gives error: Token is invalid or has expired.

    (Value of KITE_REFRESH_TOKEN is the token we get in the URL when successfull login flow)
  • sujith
    You get a request token after the successful login process. You can know more here.
  • V2R
    @sujith I tried the above api: https://api.kite.trade/session/token

    I Have generated the checksum of api_key + request_token + api_secret and then I've called the above with the respective parameters, still it gives error:
    sometimes:
    {
    "status": "error",
    "message": "`api_key` should be minimum 6 characters in length.",
    "data": null,
    "error_type": "InputException"
    }
    and sometimes:
    {
    "status": "error",
    "message": "`checksum` should be minimum 10 characters in length.",
    "data": null,
    "error_type": "InputException"
    }
    Is there something i am missing?
  • sujith
    You need to send api_key, checksum and request token as mentioned here.
Sign In or Register to comment.