Session generation started failing all of a sudden

mlearner

Hi,

All of a sudden, kite session generation method started throwing TokenException even though I tried using fresh request token multiple times. Exception trace is below. When I regenerated my API Secret key & tried again, only then access token was successfully generated. Is there an expiration time period for API Secret key?

data = kite.generate_session(request_token, api_secret=constants.API_SECRET)

Exception Trace:

Traceback (most recent call last):
File "/Users/kiteconnect_code.py", line 20, in <module>
data = kite.generate_session(request_token, api_secret=constants.API_SECRET)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/kiteconnect/connect.py", line 249, in generate_session
resp = self._post("api.token", {
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/kiteconnect/connect.py", line 821, in _post
return self._request(route, "POST", params)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/kiteconnect/connect.py", line 886, in _request
raise exp(data["message"], code=r.status_code)
<b class="Bold">kiteconnect.exceptions.TokenException: Token is invalid or has expired.
</b>[Finished in 1.1s with exit code 1]
Thanks.
Tagged:
  • rakeshr
    @mlearner
    Is there an expiration time period for API Secret key?
    No, API secret key doesn't have any expiry.

  • mlearner
    Then definitely there was an issue with session generation (during the timestamp when I attempted it) as per exception trace shared above.

    And the fact that this issue went away with API Secret key reset, makes it even more serious. We don't change API secret key frequently.

    But if this kind of issue happens again and it requires API secret key reset, it should be communicated through exception trace message.

    @rakeshr - Request to investigate internally once.
Sign In or Register to comment.