It is showing that my token in invalid or has expired.... please help !!

gaurangrathi_
i used this code in python -
from kiteconnect import KiteConnect


api_key = "7x1q*******lgv"
api_secret = "1zc771xulo**********mfn8w5hzii"
kite = KiteConnect(api_key=api_key)
print(kite.login_url())

request_token = "4gP6CI2w**********IlLCc2"
data = kite.generate_session(request_token, api_secret=api_secret)

kite.set_access_token(data["access_token"])
data = kite.generate_session(request_token,api_secret=api_secret)
kite.set_access_token(data["access_token"])


it is showing these errrors-
File "C:\Users\HP\PycharmProjects\pythonProject\pythonProject\main.py", line 13, in
data = kite.generate_session(request_token, api_secret=key_secret[1])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\HP\PycharmProjects\pythonProject\pythonProject\venv\Lib\site-packages\kiteconnect\connect.py", line 263, in generate_session
resp = self._post("api.token", params={
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\HP\PycharmProjects\pythonProject\pythonProject\venv\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\HP\PycharmProjects\pythonProject\pythonProject\venv\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.

I am new to python language.... Please help ! thankyou.
Sign In or Register to comment.