i am using kite for monitoring , nothing else , i get randomly access_token invalidated frequently . Please let me know how to make sure that it should session should expire once in a day .
let me know if i can automate process of access token .
Even am facing same issue. The token gets invalidated every 5-10 mins. It doesn't remain logged in for the entire day. I am facing this issue since yesterday (4 Dec 17).
kiteconnect.exceptions.TokenException: Invalid API credentials
We're doing quite normal operations such as using historical data every 15 mins, doing some processing, and then sleeping and waking up again after 15 mins. We login every day in the morning, but after a few periods, we see the invalid access token errors. This used to work quite well until last week. It has become more frequent since yesterday. Even today we ran into these token errors
Here's the python traceback for reference. A call to kite.historical() was made with appropriate parameters. ============ user = kite.request_access_token(request_token=ACCESS_TOKEN,secret=SECRET) File "/usr/local/lib/python3.5/dist-packages/kiteconnect/__init__.py", line 269, in request_access_token "checksum": checksum File "/usr/local/lib/python3.5/dist-packages/kiteconnect/__init__.py", line 581, in _post return self._request(route, "POST", params) File "/usr/local/lib/python3.5/dist-packages/kiteconnect/__init__.py", line 668, in _request raise(exp(data["message"], code=r.status_code)) kiteconnect.exceptions.TokenException: Invalid session credentials
In the above code, it seems like you are sending access token to get the access token. Is this how you have in the code? You need to use a fresh request token to get the access token.
ok, that was a wrong copy paste, Here's the actual traceback: ========= Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.5/dist-packages/kiteconnect/__init__.py", line 522, in historical "continuous": 1 if continuous else 0}) File "/usr/local/lib/python3.5/dist-packages/kiteconnect/__init__.py", line 577, in _get return self._request(route, "GET", params) File "/usr/local/lib/python3.5/dist-packages/kiteconnect/__init__.py", line 668, in _request raise(exp(data["message"], code=r.status_code)) kiteconnect.exceptions.TokenException: Invalid API credentials
I have got my historical data activated yestreday only, and I am also facing the same issues, it gives an error that "Invalid API Credentials", however when I re-run it, my access token doesn't change. Please not that I have not logged out, just restarted the python session. Could you please help me out.
Hi, A request token is valid for only a couple of minutes and it can be used only once. Don't request for access token for every run. Once you receive an access token, use the same for subsequent runs.
An access token is valid for one whole day. Unless you log out. If your previous access token is still active then the system will give you back the same access token which is fine.
After you subscribe to historical data, you need to re-login to use historical data API.
As mentioned earlier, it is mandatory by the exchange that a user has to log in manually at least once a day. We don't recommend automating log in.
kiteconnect.exceptions.TokenException: Invalid API credentials
Can you let us know some more details like what did you do after generating access token?
We couldn't reproduce this.
I'm commenting on behalf of Vaga:
We're doing quite normal operations such as using historical data every 15 mins, doing some processing, and then sleeping and waking up again after 15 mins. We login every day in the morning, but after a few periods, we see the invalid access token errors. This used to work quite well until last week. It has become more frequent since yesterday. Even today we ran into these token errors
============
user = kite.request_access_token(request_token=ACCESS_TOKEN,secret=SECRET)
File "/usr/local/lib/python3.5/dist-packages/kiteconnect/__init__.py", line 269, in request_access_token
"checksum": checksum
File "/usr/local/lib/python3.5/dist-packages/kiteconnect/__init__.py", line 581, in _post
return self._request(route, "POST", params)
File "/usr/local/lib/python3.5/dist-packages/kiteconnect/__init__.py", line 668, in _request
raise(exp(data["message"], code=r.status_code))
kiteconnect.exceptions.TokenException: Invalid session credentials
Is this how you have in the code?
You need to use a fresh request token to get the access token.
=========
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.5/dist-packages/kiteconnect/__init__.py", line 522, in historical
"continuous": 1 if continuous else 0})
File "/usr/local/lib/python3.5/dist-packages/kiteconnect/__init__.py", line 577, in _get
return self._request(route, "GET", params)
File "/usr/local/lib/python3.5/dist-packages/kiteconnect/__init__.py", line 668, in _request
raise(exp(data["message"], code=r.status_code))
kiteconnect.exceptions.TokenException: Invalid API credentials
I will check and get back to you.
I am facing the same issue from last couple of days. I do normal data reading. not executing any trade...still it expires within few mins.
It seems like your historical data subscription is expired.
I have got my historical data activated yestreday only, and I am also facing the same issues, it gives an error that "Invalid API Credentials", however when I re-run it, my access token doesn't change. Please not that I have not logged out, just restarted the python session. Could you please help me out.
A request token is valid for only a couple of minutes and it can be used only once. Don't request for access token for every run. Once you receive an access token, use the same for subsequent runs.
An access token is valid for one whole day. Unless you log out. If your previous access token is still active then the system will give you back the same access token which is fine.
After you subscribe to historical data, you need to re-login to use historical data API.