Error of invalid expired token

siddharth123
siddharth123 edited October 27 in Python client
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.kite.trade:443
DEBUG:urllib3.connectionpool:https://api.kite.trade:443 "POST /session/token HTTP/11" 403 None
---------------------------------------------------------------------------
TokenException Traceback (most recent call last)
Cell In[12], line 1
----> 1 data = kite.generate_session("eeeeeeeeeeeeeeeeeeeeeee", api_secret="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")

File ~\anaconda3\Lib\site-packages\kiteconnect\connect.py:263, in KiteConnect.generate_session(self, request_token, api_secret)
260 h = hashlib.sha256(self.api_key.encode("utf-8") + request_token.encode("utf-8") + api_secret.encode("utf-8"))
261 checksum = h.hexdigest()
--> 263 resp = self._post("api.token", params={
264 "api_key": self.api_key,
265 "request_token": request_token,
266 "checksum": checksum
267 })
269 if "access_token" in resp:
270 self.set_access_token(resp["access_token"])

File ~\anaconda3\Lib\site-packages\kiteconnect\connect.py:865, in KiteConnect._post(self, route, url_args, params, is_json, query_params)
863 def _post(self, route, url_args=None, params=None, is_json=False, query_params=None):
864 """Alias for sending a POST request."""
--> 865 return self._request(route, "POST", url_args=url_args, params=params, is_json=is_json, query_params=query_params)

File ~\anaconda3\Lib\site-packages\kiteconnect\connect.py:937, in KiteConnect._request(self, route, method, url_args, params, is_json, query_params)
935 # native Kite errors
936 exp = getattr(ex, data.get("error_type"), ex.GeneralException)
--> 937 raise exp(data["message"], code=r.status_code)
939 return data["data"]
940 elif "csv" in r.headers["content-type"]:

TokenException: Token is invalid or has expired.
  • sujith
    This means your session is expired and you need to generate a new access token.
Sign In or Register to comment.