Token invalid or expired issue

RDHEERAJSH
Token invalid or expired issue and Error while loading app session. Please try again. Reinitiate the login if issue persists. same issue each and every time
Tagged:
  • sujith
    You may refer to this thread.
  • RDHEERAJSH
    RDHEERAJSH edited April 10
    I am using this code for trial run
    Api key covered with "AAAAAA" while pasting here due to security reason. and also security token covered with "BBBBB" and api _ secret = with "CCCCC" security reason


    import logging
    from kiteconnect import KiteConnect
    logging.basicConfig(level=logging.DEBUG)
    kite = KiteConnect(api_key="AAAAA")
    data = kite.generate_session("request_token_here", api_secret="CCCCC")
    kite.set_access_token(data["BBBBB"])
    profile=kite.profile ()
    print (profile)
  • RDHEERAJSH
    i getting below mention error, Api Secret covered with "CCCCC" while pasting here due to security reason. and also security token covered with "BBBBB"

    Here i m using this url for generating token https://kite.zerodha.com/connect/login?api_key=AAAAA&sess_id=BBBBB

    Error paste below : ..

    C:\Users\Kasliwal\Downloads>hello.py
    DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.kite.trade:443
    DEBUG:urllib3.connectionpool:https://api.kite.trade:443 "POST /session/token HTTP/1.1" 403 None
    Traceback (most recent call last):
    File "C:\Users\Kasliwal\Downloads\hello.py", line 5, in
    data = kite.generate_session("request_token_here", api_secret="CCCCC")
    File "C:\Users\Kasliwal\AppData\Local\Programs\Python\Python310\lib\site-packages\kiteconnect\connect.py", line 263, in generate_session
    resp = self._post("api.token", params={
    File "C:\Users\Kasliwal\AppData\Local\Programs\Python\Python310\lib\site-packages\kiteconnect\connect.py", line 865, in _post
    return self._request(route, "POST", url_args=url_args, params=params, is_json=is_json, query_params=query_params)
    File "C:\Users\Kasliwal\AppData\Local\Programs\Python\Python310\lib\site-packages\kiteconnect\connect.py", line 937, in _request
    raise exp(data["message"], code=r.status_code)
    kiteconnect.exceptions.TokenException: Token is invalid or has expired.
  • sujith
    The solution is provided in the above mention thread.
  • RDHEERAJSH
    ok done close this discussion
This discussion has been closed.