KiteConnect Codes that worked one day ago,, do not work now

I am literally following the instructions on numerous documentations and online videos and this was working up until 2 days ago.
Could someone point out if the fact that I've been moved up to Kiteconnect 3.0 is causing this trouble?

Codes are shown in the picture. I have erased
my api key and secret even if there was not real need for that.
  • Vivek
    Please DM me your api_key. I couldn't find any app associated with your email id.
  • manuhegde
    Just sent it, thanks for taking the time!
  • manuhegde
    Hey, Has anyone else been facing similar issues?
  • ankur0101
    @manuhegde why dont you use requests module from python? I dont prefer to use any library, I am more confident with direct Rest API.

    Try it and check.
  • manuhegde
    Hi Ankur,
    I am quite new to Python, so at this time I am fumbling along the best I can!
    Any codes you can share will be greatly appreciated!
  • manuhegde
    For now I have gotten V 3.7.0b9 installed through the CMD terminal using this command:
    pip install kiteconnect --upgrade --pre --user

    I have stored my api key and api secret and and going to my kite.login_url()getting the access token and trying to run this:

    (Of course I keep changing the token as it changes each time)

    My error is this:

    TokenException Traceback (most recent call last)
    <ipython-input-11-c58bba67d748> in <module>()
    ----> 1 kite.request_access_token("adOzoxvRNPftf8TDjEeKlY1kFmqsnQYq",api_secret)

    ~\Anaconda3\lib\site-packages\kiteconnect\ in request_access_token(self, request_token, secret)

    ~\Anaconda3\lib\site-packages\kiteconnect\ in _post(self, route, params)

    ~\Anaconda3\lib\site-packages\kiteconnect\ in _request(self, route, method, parameters)

    TokenException: Invalid session credentials
  • manuhegde
    Also, the documentation says that for V3.7.0b9 we need to use generate_session, which gives me this error
    AttributeError Traceback (most recent call last)
    <ipython-input-12-da8fb0c37b90> in <module>()
    ----> 1 kite.generate_session("loZgeGq6zFxSvQjMbF5XgdR3JA2Led4f",api_secret)

    AttributeError: 'KiteConnect' object has no attribute 'generate_session'
  • zartimus
    @manuhegde pip show kiteconnect will show you the kiteconnect version installed (it should be 3.7.0b9).
    will help you get the access token provided you have mentioned the redirect url correctly. (
  • manuhegde
    Hi @zartimus, that is the version I have - neither generate_session or request_access_token are working. Will try the flask code now.

    Sent a mail to [email protected] - hoping for the best.
  • manuhegde
    @vivek , is there a phone number we can call?
  • zartimus
    @manuhegde we do not provide telephonic support cannot happen if you have upgraded it.

    Can you check your kiteconnect version again?
    `pip show kiteconnect` Please post the output here
  • pvgeorge
    check for pip show service_identity, apparently you are missing some dependencies.
  • manuhegde
    Hi All, thank you for the comments.
    I have attached the outputs of the pip show commands

    @zartimus : I did run that code and we do see Kiteconnect V3.7.0b9.
    I have installed all the pre-requisites of this package too.

    @pvgeorge : It appears we have service_identity 17.0.0
    I checked for each pre-requirement here and all of them are installed too.


  • pvgeorge
    The first screen shot from you was showing the old login procedure. There are changes in the new system.

    Login procedure from the new docs!

    # Redirect the user to the login url obtained
    # from kite.login_url(), and receive the request_token
    # from the registered redirect url after the login flow.

    # Once you have the request_token, obtain the access_token
    # as follows.

    data = kite.generate_session("request_token_here", api_secret="your_secret")

  • pvgeorge
    Sorry Manu, when started reading back on the discussion I didn't read the thread complete, the reason for above reply.

    If your kiteconnect upgrade is proper when you write kite. and wait, the available attributes will be displayed. Check if generate_session is displayed.
  • pvgeorge
    Or better, get attributes by dir(kite).
  • zartimus
    @manuhegde Assuming you are getting `AttributeError: 'KiteConnect' object has no attribute 'generate_session'` and you have kiteconnect v3.7.0b9 in the sitepackages. Can you make sure the python shell uses the same pythonpath where the above packages are installed? Maybe you have multiple python installation.
  • manuhegde
    manuhegde edited March 2018
    @zartimus I did do that, so now 'request_access_token' doesnot work and generate_session kind of working.
    So progress - Yayy!

    The issue is that it constantly says the token is invalid or expired. I will send screenshots of my misadventures.
    They are as follows

    1) We look to generate login_url
    2) Paste login url into chrome and get a request token
    3) Successfully login (to Kite on Chrome web browser)
    4) Use request token to try to get access token through generate_session().
    I have also tried data=kite.generate_session(...)

  • pvgeorge
    From the screen shots, what you are selecting is not request_token, it is sess_id. sess_id may be session_id but not request_token. The address bar will change and contain request token if login is proper with redirect url in app.
  • manuhegde
    Hey @pvgeorge, But after a proper login (where I get into the account) as shown above, it simply changes the url to -

    There are no more tokens to be copied!
  • pvgeorge
    One place to Check is the redirect url in your app.
  • manuhegde
    Hi, would you be able to show a screenshot of where to look.. Because immediately after login to the Url I get into the page.
  • manuhegde
    Like immediately after my screenshot 2 I go to screenshot 3.. And I'm sure you would notice that screenshot 3 has no tokens in the Url...
  • pvgeorge
    @manuhegde you have to wait for the zerodha team. I am another user like you who faced similar problems.
  • manuhegde
    @pvgeorge - Sure thing! I thought you worked with them! :) Good luck with your issues and thanks for all your help!
Sign In or Register to comment.