generate_session | code gives error

kamaralikhan
I have done all the steps to connect to KiteConnect session. But the code is give me error.

Note that all the steps are taken to generate request token. please assist at earliest.
Note that the same steps when performed from Ipython console, it works and i am able to place the order as well.

#---Python Code
from kiteconnect import KiteConnect
kite = KiteConnect(kconf.KITE_API_KEY)
data = kite.generate_session("bu5pqaw7j7w6CihJbqV014t4wzyMExVk",
api_secret= kconf.KITE_API_SECRET)
kite.set_access_token(data["access_token"])
#-----------end.

When i run the code i get following error
File "C:\Users\OFFICE\AppData\Roaming\Python\Python36\site-packages\kiteconnect-3.7.4-py3.6.egg\kiteconnect\connect.py", line 766, in _request
raise exp(data["message"], code=r.status_code)

InputException: Missing or invalid field `api_key`. Min length is 6.

This discussion has been closed.