Invalid Api Credentials

noor
Hello Sujiit,
I have Kite Connect app and also subscribed for historical data to access this API. But still I am getting an error as " TokenException: Invalid API credentials". and also the following are shown as errors.

TokenException Traceback (most recent call last)
in ()
92 strategy(records)
93
---> 94 start()

in start()
89
90 def start():
---> 91 records = get_historical_data()
92 strategy(records)
93

in get_historical_data()
21 # Gets historical data from Kite Connect
22 def get_historical_data():
---> 23 return kite.historical(instrument_token, from_date, to_date, interval)
24
25 """

~\Anaconda3\lib\site-packages\kiteconnect\__init__.py in historical(self, instrument_token, from_date, to_date, interval, continuous)
536 "to": to_date,
537 "interval": interval,
--> 538 "continuous": 1 if continuous else 0})
539
540 records = []

~\Anaconda3\lib\site-packages\kiteconnect\__init__.py in _get(self, route, params)
591 def _get(self, route, params=None):
592 """Alias for sending a GET request."""
--> 593 return self._request(route, "GET", params)
594
595 def _post(self, route, params=None):

~\Anaconda3\lib\site-packages\kiteconnect\__init__.py in _request(self, route, method, parameters)
682 code=r.status_code))
683 elif exp:
--> 684 raise(exp(data["message"], code=r.status_code))
685 else:
686 raise(ex.GeneralException(data["message"], code=r.status_code))

TokenException: Invalid API credentials

  • noor
    Can anybody help me to solve the problem. I am using jupiter notebook and spyder to run this code. I have bought kiteconnect and historical api subscribed. But still I am getting this error.
  • sujith
    Hi,
    Can you let us know more details?
    When you logged into App? Are you using Pi or NEST for monitoring?
    What about other API calls, is it working?
  • sujith
    If you could let us know what you are doing after generating an access token, it would be helpful.
  • noor
    Hi Sujith,

    Thanks for your response.

    I am surprised to know about pi and nest for monitoring. I am not aware of using pi or nest! I just tried backtesting in ipython notebook. Because, when I tried simple buy order it worked well. But streaming SMA is giving a problem as invalid API credentials.

    I believe I am in the right direction to your question.
    If not please correct me.

  • prat
    @noor i guess the reason @sujith asked about PI is because the Token is invalidated when you login to PI.
    More information is needed here as to where are you storing you Token and how are you passing it to your code.
    Without which its really difficult to tell what the issue may be.
  • noor
    Dear Prat and Sujit
    Thanks to both of you for giving me the solution.
    Noor
This discussion has been closed.