facing TokenException

Hi.. I am getting the below error for "kite.positions()"
kiteconnect.exceptions.TokenException: Incorrect `api_key` or `access_token`..But i am successfully generate accesstoken and able to subscribe the symbols.Help is much appriciated.
  • sujith
    Are you sure, you are not calling generateSession again?
  • Dileep
    Hi @sujith . I am not calling generate session again.If you want i will send my API KEY.
  • sujith
    You can run javakiteconnect with debug flag and paste the complete error json with status code here.

    Also paste the response and status code of the api that is successful also.

    PS: Make sure to remove app or client specific tokens.
  • Dileep
    Dileep edited November 2021
    Hi @sujith ,

    I am using python client. This is below my code.

    from kiteconnect import KiteConnect
    print("Successfully fetched the Instruments")
    a= kite.positions()
    print("Successfully fetched the Positions")
    except Exception as e:

    Console Output:

    Successfully fetched the Instruments
    Invalid `api_key` or `access_token`.
    SRIJAN edited November 2021
    You have to use kite.set_access_token. Otherwise it won't work. Follow the proper documentation.
  • Dileep
    Thanks @sujith @SRIJAIN. Now i am able to fetch . You can close this discussion.
This discussion has been closed.