access token for zerodha kite3

Ashok121
Hello,

I am getting following error while generating access token for kite3: Please guide me.

(kite3) 17:18 ~/krish $ ipython
Python 3.6.0 (default, Jan 13 2017, 00:00:00)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from kiteconnect import KiteConnect
In [2]: api_key="xxxx"
In [3]: api_secret="xxxxx"
In [4]: kite=KiteConnect(api_key,api_secret)
In [5]: kite.login_url()
Out[5]: 'https://kite.trade/connect/login?api_key=xxxxx&v=3'
In [6]: kite.request_access_token("w1vCPQjMkck31F10s71m0pQ0ImWNVBZ8",api_secret)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
in ()
----> 1 kite.request_access_token("w1vCPQjMkck31F10s71m0pQ0ImWNVBZ8",api_secret)
AttributeError: 'KiteConnect' object has no attribute 'request_access_token'
In [7]:
Tagged:
  • tonystark
    "request_access_token" has changed to "generate_session" in version 3. You can find the change log here and find the new docs here.
  • Ashok121
    data = kite.generate_session("request_token_here", secret="your_secret")kite.set_access_token(data["access_token"])

    Is above in one line?
  • Ashok121
    Any webinar on this?
  • sujith
    sujith edited February 2018
    The link for webinar is here.
  • Ashok121
    1. import logging
    2. from kiteconnect import KiteConnect
    3. logging.basicConfig(level=logging.DEBUG)
    4. kite = KiteConnect(api_key="my api key")
    # my request token from "https://kite.trade/connect/login?api_key=xxxxx&v=3" and login.
    5. data = kite.generate_session("my request token",api_secret="my api secret")

    7. kite.set_access_token(data["access_token"])

    Please correct if above steps are not correct or anything missing. becuase with above even I am not able to get access token in ipython and getting message " Invalid token".
  • ssashita
    ssashita edited May 2018
    I would like to know if an access_token generated by logging in from one session is constrained to be used only from that session, or whether it can be additionally be used for things like getting LTP in a python/node script
  • sujith
    Once an access token is obtained it can be used for anything.
Sign In or Register to comment.