"Token is invalid or has expired"

ZR2734
Trying to connect with kiteconnect developer API through my python code. Receiving error in response i.e. "Token is invalid or has expired".

I have attached error image that I am receiving on terminal.

For more reference you can see my python code :

kite = KiteConnect(api_key="XXXXXXXXXXXXX")
url = kite.login_url()
response = requests.get(url)
redir_url = response.history[1].headers['Location']
request_token = urlparse(redir_url).query.split('&sess_id=')[1]
secret_api="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
data = kite.generate_session(str(request_token), api_secret=secret_api)
kite.set_access_token(data["access_token"])


Your quick help and response is appreciated !!
Thank you advance ..

  • rakeshr
    @ZR2734
    request_token = urlparse(redir_url).query.split('&sess_id=')[1]
    What you are getting here is session_id not request token.You have to generate request_token by opening login link in browser and then login to kite.You can check the flow here.
  • ZR2734
    On Friday, I have already posted my query and comment against this token, still i have not received any response from you !!
    Please reply me ASAP. Its really urgent.

    Your help and response appreciates !!
  • rakeshr
    @ZR2734
    Reason for error is explained above,
    What you are getting here is session_id not request token
    .Please go through this thread.
Sign In or Register to comment.