Request Token Generation problem

reddy4305
Hi,
I tried to generate Request token using kite.login_url() with my API key, but after redirect and login with password and 2fa, the following error is being generate. Please Help

{
"error_type": "InputException",
"message": "Provide at least one `refresh_permission`.",
"status": "error"
}
  • sujith
    @reddy4305,
    Are you using the generate_session method?
  • reddy4305
    yes Sujith, i am using the generate_session method as following. My user ID is ZT7008

    data = kite.generate_session("request_token_here", api_secret="your_secret")
    kite.set_access_token(data["access_token"]),
  • sujith
    It should be fine now. Can you check?
  • reddy4305
    reddy4305 edited February 2018
    Thanks Sujith, now my request token is being generated properly on using the url.
    But when I input it in generate session as following, I am getting a token is invalid or expired error.
    from kiteconnect import KiteConnect
    kite = KiteConnect(api_key="xxxxxxxxxxxxxxxxxxxxxxxxxx")
    kite.login_url()
    data = kite.generate_session("request_tokenxxxx", api_secret="xxxxxxxxxxxxxxxxxxxxxxxx")
    kite.set_access_token(data["access_token"])
    Error:
    TokenException Traceback (most recent call last)
    in ()
    3 kite = KiteConnect(api_key="xxx")
    4 kite.login_url()
    ----> 5 data = kite.generate_session("AzSKpa34L15yK7BwRIkQdQAqgkr9JGl0", api_secret="xx")
    6 kite.set_access_token(data["access_token"])
    7

    C:\Anaconda\lib\site-packages\kiteconnect\connect.py in generate_session(self, request_token, api_secret)
    226 "api_key": self.api_key,
    227 "request_token": request_token,
    --> 228 "checksum": checksum
    229 })
    230

    C:\Anaconda\lib\site-packages\kiteconnect\connect.py in _post(self, route, params)
    671 def _post(self, route, params=None):
    672 """Alias for sending a POST request."""
    --> 673 return self._request(route, "POST", params)
    674
    675 def _put(self, route, params=None):

    C:\Anaconda\lib\site-packages\kiteconnect\connect.py in _request(self, route, method, parameters)
    736 # native Kite errors
    737 exp = getattr(ex, data["error_type"], ex.GeneralException)
    --> 738 raise exp(data["message"], code=r.status_code)
    739
    740 return data["data"]

    TokenException: Token is invalid or has expired.

  • sujith
    @reddy4305,
    Make sure you don't post your api_key, api secret or any tokens on public threads. You can use the private message for sending these stuff.
    Check out this thread for more information about this issue.
Sign In or Register to comment.