kiteconnect.exceptions.TokenException: Token is invalid or has expired.

VulturesPick
kiteconnect.exceptions.TokenException: Token is invalid or has expired.

I have used your API long time back in 2015. I am trying again but I am getting below message.

kiteconnect.exceptions.TokenException: Token is invalid or has expired.

I generated my API key and secret today only.

Below is my Code tat I am using.

import logging
from kiteconnect import KiteConnect
from kiteconnect import KiteTicker
logging.basicConfig(level=logging.DEBUG)
# Initialise
kite = KiteConnect(api_key=API_Key)
data = kite.generate_session("request_token_here",api_secret=API_Secret)
print(data)

how do I solve this?

Thnx
Tagged:
  • VulturesPick
    Hi

    I Changed the redirect URL to http://127.0.0.1. That stops giving invalid API_Key error but I am now getting below error

    kiteconnect.exceptions.TokenException: Token is invalid or has expired.

    What can I do to get rid of this error?

    Thnx
  • sujith
    Can you private message the api_key and client id? We will check and get back to you.
  • VulturesPick
    VulturesPick edited August 2023
    BTW what is the requirement for giving postback url. can I give any of my website url that I have from godaddy or something else is required?

    thnx
  • sujith
    You can give any https link that accepts the post request and make sure to respond with 200 first and then do your calculations. The timeout for postback is too low, if you don't respond then it will be considered as timeout.
  • VulturesPick
    is there any standard postback url that you privides during testing and development phase?
  • VulturesPick
    I am in very initial stage where i want to get some real time data for nifty50 options at 5 minute interval, do my calculations locally to check if my strategy is worth pursuing
  • VulturesPick
    so practically i dont need to post anything. my case as of now is single user and offline development with the data received. afterwards also i will first trade myself for some time before making my strategy public
  • VulturesPick
    So can somehow i work without setting postback url or any standard url that you have for developers
  • sujith
    It is optional, you can choose not to set postback url. You can listen to order updates via Websockets API.
  • VulturesPick
    VulturesPick edited August 2023
    But API can not be created without giving postback url. Do u think if I give my general https url there and use websockets then it will work
  • sujith
    Only redirect url is compulsory. Postback URL is optional.
  • VulturesPick
    No while generating API - it doesn’t let go further unless postback url is given
  • sujith
    Can you private message the screenshot of the error, while creating the Kite Connect app or modifying Kite Connect app?
  • VulturesPick
    Connection issue is resolved. Main confusion is request_token and access_token. Somehow it does not become clear first time which one is what, where to get from and how to use them.
This discussion has been closed.