TokenException: Token is invalid or has expired.

hiwarekar
Step 1. Executed this code
import logging
from kiteconnect import KiteConnect

logging.basicConfig(level=logging.DEBUG)
api_secret="xxxxxxxxxxxxxxxxxxxxxxx"
kite = KiteConnect(api_key="xxxxxxxxxxxxx")
kite.login_url()

out: 'https://kite.trade/connect/login?api_key=xxxxxxxxxxxx&v=3'
Step 2: Pasted this to browser to get request token
Step 3: Copied request token and pasted in code below

data = kite.generate_session("xxxxxxxxxxxxxxxxxxxxxx", api_secret)

Now getting this error every time:
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.kite.trade
DEBUG:urllib3.connectionpool:https://api.kite.trade:443 "POST /session/token HTTP/1.1" 403 None

---------------------------------------------------------------------------
TokenException Traceback (most recent call last)
in ()
----> 1 data = kite.generate_session("xxxxxxxxxxxxxxxxxxx", api_secret)

~\Anaconda3\lib\site-packages\kiteconnect-3.7.4-py3.6.egg\kiteconnect\connect.py in generate_session(self, request_token, api_secret)
230 "api_key": self.api_key,
231 "request_token": request_token,
--> 232 "checksum": checksum
233 })
234

~\Anaconda3\lib\site-packages\kiteconnect-3.7.4-py3.6.egg\kiteconnect\connect.py in _post(self, route, params)
699 def _post(self, route, params=None):
700 """Alias for sending a POST request."""
--> 701 return self._request(route, "POST", params)
702
703 def _put(self, route, params=None):

~\Anaconda3\lib\site-packages\kiteconnect-3.7.4-py3.6.egg\kiteconnect\connect.py in _request(self, route, method, parameters)
764 # native Kite errors
765 exp = getattr(ex, data["error_type"], ex.GeneralException)
--> 766 raise exp(data["message"], code=r.status_code)
767
768 return data["data"]

TokenException: Token is invalid or has expired.

Just for info got this error while installing
https://kite.trade/forum/discussion/4335/could-not-find-egg-info-directory-in-install-record-for-kiteconnect#latest

Where is the problem?
  • h3h3
    @sujith having the same issue, this was working for me till yesterday, today it's throwing this error.

    What's the problem?
  • h3h3
    h3h3 edited August 2018
    And as i'm looking through the error, has something to do with security check and captcha.

    Also i'm getting the attention required and captcha page today, before the login page of kite.

    Is this a cloudflare issue?
  • h3h3
    never mind, solved it :#
This discussion has been closed.