Not receiving session token and other profile details

amitnifty75
Hi,
I'm not recceiving access_token. Receving below given debud msgs. Please let me know where I'm going wrong

DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.kite.trade:443
DEBUG:urllib3.connectionpool:https://api.kite.trade:443 "POST /session/token HTTP/11" 200 None
DEBUG:urllib3.connectionpool:https://api.kite.trade:443 "GET /user/margins HTTP/11" 200 None
DEBUG:urllib3.connectionpool:https://api.kite.trade:443 "GET /portfolio/holdings HTTP/11" 200 None
  • tonystark
    You seem to authenticated given the 200 responses for all the API calls. Which library are you using? Any example code?
  • amitnifty75

    api_key="my api key"

    api_secret="my api secret"

    import logging
    from kiteconnect import KiteConnect

    logging.basicConfig(level=logging.DEBUG)

    kite = KiteConnect(api_key=api_key)

    # kite.login_url()
    print("Login URL : ", kite.login_url())


    request_token = input('your_request_token: ')

    data = kite.generate_session(request_token, api_secret = api_secret)

    kite.set_access_token(data['access_token'])

    kite.margins()

    kite.holdings()
  • sujith
    You can refer to this thread.
  • amitnifty75
    Hi, when I am running single line code on python commandline or Jupyter, it's working and giving debug msg with details. Earlier shown msg was when I was executing .py file

    Getting below msg when running single line code -------

    >>> data = kite.generate_session(request_token, api_secret = apisecret)
    DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.kite.trade:443
    DEBUG:urllib3.connectionpool:https://api.kite.trade:443 "POST /session/token HTTP/11" 200 None
    >>> kite.set_access_token(data["access_token"])
    >>> kite.margins()
    DEBUG:urllib3.connectionpool:https://api.kite.trade:443 "GET /user/margins HTTP/11" 200 None
    {'equity': {'enabled': True, 'net': 28.1, 'available': {'adhoc_margin': 0, 'cash': 28.1, 'opening_balance': 28.1, 'live_balance': 28.1, 'collateral': 0, 'intraday_payin': 0}, 'utilised': {'debits': 0, 'exposure': 0, 'm2m_realised': 0, 'm2m_unrealised': 0, 'option_premium': 0, 'payout': 0, 'span': 0, 'holding_sales': 0, 'turnover': 0, 'liquid_collateral': 0, 'stock_collateral': 0, 'equity': 0, 'delivery': 0}}, 'commodity': {'enabled': False, 'net': 0, 'available':

  • sujith
    These are just debug logs. You can disable debug logs while initializing the pykiteconnect library.
  • amitnifty75
    ok, but my concern is when I run .py file on command line i dont get any results like margin, holding.....

    but when I am running individual code line from same .py file one by one on python commnad line or jupyter, its showing results like margin, holdings, etc.
  • amitnifty75
    Got the solution, thanks for the support
This discussion has been closed.