How to get request_token , when the redirect URL is http://127.0.0.1?

RK2245
I have created an APP and configured the redirect URL to 127.0.0.1 , how can i get the request token from the redirect URL?
Tagged:
  • sujith
    Hi,
    After successful login, you will be redirected to registered redirect url. In your case something like this http://127.0.0.1/?status=success&request_token=fqvqwkw9xgqavd0b2xn29kb08aqxdafd

    Just copy request token and use it.
  • RK2245
    Hi,

    After login i was redirected a URL with session ID, i wasn't redirected to to the above URL.
    I assume, i should be able to get the request token programatically, by accessing the redirection url.

    Thanks
  • sujith
    Hi,
    If you are looking at session id then you are not logged in. BTW you can only use client id which you have specified while creating App.
  • RK2245
    Hi,

    I am providing, api key, client ID (as userID) to get the login URL.After getting the login URL, i am making a connection request and hoping to get redirected to the redirection URL.But that doesn't happen.

    For useId , i have tried both mail Id and client id, but still i am not able to get hold of access token.
  • sujith
    You have to login on browser, it doesn't work with code. It is mandatory to manually login everyday once because of exchange regulation.
  • RK2245
    Hi ,
    If i understand right,
    I have to
    1 . login manually to https://kite.zerodha.com/connect/login?api_key=XXXXXX
    2. Which asks for client id and password, later security question
    3 .On successful login, i will be able to capture the request token from the browser address bar (Manually)
    4. later use the request token for any further interaction (programitacally) with the platform
    5. Everytime the session expires, i should follow the steps 1 to 4 again

    Pls correct if the understanding is wrong.
  • sujith
    Hi @RK2245,

    Yes you are right. Your access token is valid for one day unless you use some other platform.
  • RK2245
    I have logged out of all platform.But still seems like i have to get the access token for every request.
    I get session expired after every request.Am i missing anything?

  • narasimha
    Hello Team,

    I am also facing the same thing, every request getting session expired.
  • narasimha
    Hello Team,

    Can any one reply
  • sujith
    Hi @narasimha,
    Once you fetch access token, store it somewhere and use the same. Don't request for access token every time you run App.
  • llpach
    llpach edited August 2017
    Hi,
    Like in .net do we have below kind of code in java which will set request_token automatically
    "Kite.Login() ‘Login to Kite using Web Browser.
    This library comes with a Web Browser control that will be used to Login and the Request token is automatically set.Client need not to copy the request token and set it manually."
  • vishalgvora
    Hello,
    I am using following method, it may help...
    1. Every morning i login manually, and get the request token.
    2. feed the token to my app, function called requestAccessToken, which return access token.
    3. App will set access token for current section, also store access token to local storage for future use.
    4. if my app restart, it will fetch access token from local storage, and get my margin , if get margin function success my access token is valid. if margin function throw error it will wait for new request token and as soon as get the request token step 1,2,3 will be repeated.

    it is working for me without any error.
  • llpach
    Hi @vishalgvora,

    Thanks for the response, actually i am following the same steps but what's the use of automation then, if some network error occurs and session becomes invalid then again i have to follow the same steps manually. That's why i was looking for the solution. Have you handled for such situation or can any one give solution for this?
  • sujith
    @llpach,
    It is mandatory by the exchange that a trader has to log in manually at least once a day. Hence we don't recommend automating login.
This discussion has been closed.