Navigation

    SmartAPI Forum
    • Register
    • Login
    • Search
    • Categories
    • Popular
    • Groups
    • FAQs
    • API Docs
    1. Home
    2. P187170
    P
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 1
    • Best 0
    • Groups 0

    P187170

    @P187170

    0
    Reputation
    1
    Profile views
    1
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    P187170 Unfollow Follow

    Latest posts made by P187170

    • TOTP generated using pyotp is not validating in SmartAPI login (Invalid totp AB1050)

      Hello SmartAPI Team,

      I am trying to authenticate using the SmartAPI Python SDK with TOTP enabled.

      However, the login request consistently returns the following error:

      Error Code: AB1050
      Message: Invalid totp

      Details of my setup:

      • Python version: 3.13
      • Library: smartapi-python
      • TOTP generated using: pyotp
      • Authentication method: client_id + password + totp

      My login code:


      from SmartApi import SmartConnect
      import pyotp

      api_key = "API_KEY"
      client_id = "CLIENT_ID"
      password = "PASSWORD"
      totp_secret = "SECRET_KEY"

      totp = pyotp.TOTP(totp_secret).now()

      obj = SmartConnect(api_key)

      data = obj.generateSession(client_id, password, totp)

      print(data)

      Troubleshooting steps already performed:

      1. Verified that TOTP generated using pyotp matches the TOTP generated using online generator:
        https://totp.danhersam.com

      2. Verified that the same secret key produces identical OTP in multiple generators.

      3. System time synchronized with internet time server.

      Despite this, SmartAPI login still returns:

      {
      "status": False,
      "message": "Invalid totp",
      "errorcode": "AB1050"
      }

      Could you please clarify:

      1. Is there a specific method required to generate TOTP for SmartAPI?
      2. Does SmartAPI require TOTP generated from the SmartAPI TOTP enable page specifically?
      3. Are there any restrictions on authenticator apps (Google Authenticator / Microsoft Authenticator)?

      Any guidance would be greatly appreciated.

      Thank you.

      posted in Python SDK
      P
      P187170