Access token expired frequently and valid just for one order.

santhoshjoys
I am new to Python and Kite Connect API. I am trying to place order using Python. I have attached the simple Python code that I wrote for testing purpose and order has been successfully executed. But the problem is, I can able to place only one order and then getting access token error. When I make fresh login in Kite Web and provide new request_token, I can able to place the fresh order. But it keeps repeating, that is access token expires frequently. Anyone help me with this issue and thanks in advance.


Code.jpg 136.8K
  • rakeshr
    You don't need to use generate_session for every run. You can directly set access_token kite.set_access_token("your obtained access token"), post successfully generating access token once. The access token is valid for a day. Go through the FAQs to know more.
  • santhoshjoys
    It works. Thanks a lot.

    But, here I need to obtain the access token manually and then to enter it in the code. Is there any other way to obtain the access token automatically? Like it obtain in the above code using data = kite.generate_session and it is stored in the data["access_token"] variable.
  • rakeshr
    Is there any other way to obtain the access token automatically?
    It is mandatory by the exchange that a trader has to log in manually at least once in a day. We don't recommend automating the login. Go through the login FAQs here.
Sign In or Register to comment.