TokenException: Token is invalid or has expired.

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

kite = KiteConnect(api_key="xxxxxxxxxxxxx")

out: ''
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):
DEBUG:urllib3.connectionpool: "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\ in generate_session(self, request_token, api_secret)
230 "api_key": self.api_key,
231 "request_token": request_token,
--> 232 "checksum": checksum
233 })

~\Anaconda3\lib\site-packages\kiteconnect-3.7.4-py3.6.egg\kiteconnect\ 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)
703 def _put(self, route, params=None):

~\Anaconda3\lib\site-packages\kiteconnect-3.7.4-py3.6.egg\kiteconnect\ 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)
768 return data["data"]

TokenException: Token is invalid or has expired.

Just for info got this error while installing

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.