Problem while running my algo - TOTP inpute exception error

LQCAP
Dear Sir,

While I am running my algo i am getting the below mentioned error.
" InputException: TOTP is mandatory to place orders on third-party apps. Learn how to set up TOTP for your account [here](https://support.zerodha.com/category/your-zerodha-account/login-credentials/login-credentials-of-trading-platforms/articles/time-based-otp-setup-mobile-only). "

Please guide me through solution for solving the aforesaid error.

Thanking you

Yours Faithfully

Bhavik Raval
+91 7977030661
  • Imran
    Hi @LQCAP
    If you want to place orders through Kite API, then you need to enable TOTP for your Zerodha account.
    For TOTP setup refer this link
  • LQCAP
    yes i have done but yet algo is running for 1-2 times but again showing the same error
  • LQCAP
    same message of error is displayed
  • Imran
    You need to delete the previous access token and generate a new access token by logging into API again.
  • nedlloyd
    nedlloyd edited February 2022
    am i doing something wrong. i am still seeing the error after generating the token

    dir_path=os.path.normpath(os.getcwd() + os.sep + os.pardir)
    dir_path2=os.path.dirname(os.path.realpath(__file__))
    api_key=open(dir_path2 +"\\Access Details\\" +"api_key.txt","r").read()
    access_token=open(dir_path2 +"\\Access Details\\" +"access_token.txt","r").read()
    kite=KiteConnect(api_key=api_key)
    kite.set_access_token(access_token)


    def booksell_order():
    kite.place_order(variety=kite.VARIETY_REGULAR,
    exchange=kite.EXCHANGE_NSE,
    tradingsymbol="ACC",
    transaction_type=kite.TRANSACTION_TYPE_SELL,
    quantity=1,
    product=kite.PRODUCT_MIS,
    order_type=kite.ORDER_TYPE_MARKET)

    booksell_order()
  • SRIJAN
    What's the error you are getting??
  • nedlloyd
    I have already enabled the totp and regenerated the token.

    Below is the full error message. not sure if i have overlooked something

    Traceback (most recent call last):
    File "C:\Users\Ned\Desktop\Algo\test.py", line 29, in
    booksell_order()
    File "C:\Users\Ned\Desktop\Algo\test.py", line 21, in booksell_order
    kite.place_order(variety=kite.VARIETY_REGULAR,
    File "C:\Users\Ned\AppData\Local\Programs\Python\Python38\lib\site-packages\kiteconnect\connect.py", line 355, in place_order
    return self._post("order.place",
    File "C:\Users\Ned\AppData\Local\Programs\Python\Python38\lib\site-packages\kiteconnect\connect.py", line 841, in _post
    return self._request(route, "POST", url_args=url_args, params=params, is_json=is_json, query_params=query_params)
    File "C:\Users\Ned\AppData\Local\Programs\Python\Python38\lib\site-packages\kiteconnect\connect.py", line 913, in _request
    raise exp(data["message"], code=r.status_code)
    kiteconnect.exceptions.InputException: TOTP is mandatory to place orders on third-party apps. Learn how to set up TOTP for your account [here](https://support.zerodha.com/category/your-zerodha-account/login-credentials/login-credentials-of-trading-platforms/articles/time-based-otp-setup-mobile-only).
    [Finished in 3.1s]
  • rakeshr
    We tried reproducing at our end using the same param. With TOTP enabled, the order is going fine for all the further requests.
    Make sure, you are using the same client id as added in the developer console.
  • SRIJAN
    It clearly says that you haven't enabled totp. Did you setup totp once and then disabled it??
  • nedlloyd
    Yes, i had disabled it once but enabled it later before running the script , was trying to automate it using pyotp
  • SRIJAN
    Once you enable totp again,you have to regenerate access token.
Sign In or Register to comment.