Geeting request token.

MadhuSingh
Hi,

How to get request_token information after getting url from kite.login_url().
I tried using requests.get() for the url received from kite.log_url() but I am not getting request_token as in web browser but getting session_id and api_key values.

Thanks for help.

Regards,
Madhu
  • sujith
    Hi @MadhuSingh,
    It is not recommended to automate login as it is mandatory by the exchange that user has to log in manually at least once a day.
    You have to log in on the browser to get a request token.
  • MadhuSingh
    "request_token The one-time token obtained after the login flow. This token’s lifetime is only a few minutes and it is meant to be exchanged for an access_token immediately after being obtained"

    Can i reuse it or it expires in 5 minutes, if it expires in 5 minutes then do I need to follow this procedure every 5 minutes?
  • sujith
    Hi @MadhuSingh,
    Once you get access_token, it is valid for one whole day. You don't have to request for access_token every time you run your script.
    Once you get access_token store it and reuse it when you run script next time.
    You need to get request_token only if the access_token is expired.
  • MadhuSingh
    MadhuSingh edited April 2017
    So thanks a lot for this information.

    I have following followup Questions
    1: Is it separate for separate Exchanges or it is something specific to Zerodha.
    2. Do I need to get access_token values only during day exchange open times or if I take 5 am in morning then this will hold good for all exchanges for whole of day?
    3. How the APIs behaves if my script restarts as I need to have a new object "kite = KiteConnect( api_key = api_key )" with this call
  • sujith
    @MadhuSingh,
    access_token is for API authentication, Hence it is for one Zerodha client.
    access_tokens are flushed every day between 7:00 AM to 8:00 AM. It is recommended to get access_token at or after 8:30 AM.
    For monitoring, use Kite and not NEST or PI. If you log into PI or NEST then your previous session is cleared whereas if you use kite it will reuse session.
    If you log out of kite, you will be logged out everywhere.
    How the APIs behaves if my script restarts as I need to have a new object "kite = KiteConnect( api_key = api_key )" with this call
    It doesn't matter as long as you have valid session credentials. Just make sure you don't hit API rate limit. You can make only 3 requests per second.
Sign In or Register to comment.