Navigation

    SmartAPI Forum
    • Register
    • Login
    • Search
    • Categories
    • Popular
    • Groups
    • FAQs
    • API Docs

    TOTP Invalid (AB1050) even with correct code in Python & Google Authenticator

    Python SDK
    1
    1
    6
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      S565246 last edited by

      Hello SmartAPI Team,

      I am facing a TOTP login issue with the SmartAPI Python SDK.
      Details of my setup:

      Client ID: S565246

      API Key: (provided in .env, verified correct)

      TOTP Secret: From SmartAPI, stored in .env exactly as given (Base32 format, no spaces)

      MPIN: Correct and working in mobile app

      Python Library: pyotp

      System Time: Synced with NTP, matches phone time

      What’s happening:

      The TOTP code generated in Python matches exactly with the one shown in Google Authenticator.

      Despite that, every login attempt returns:

      "status": false,
      "message": "Invalid totp",
      "errorcode": "AB1050",
      "data": null

      Tried 3 attempts with fresh codes; same result every time.

      This happens even immediately after generating the TOTP, well within the 30-second validity window.

      Steps already tried:

      Verified .env secret matches the one provided on SmartAPI portal.

      Removed spaces and ensured all uppercase letters.

      Synced PC time with internet time servers.

      Confirmed Python-generated TOTP = Google Authenticator TOTP.

      Retried after waiting a few minutes in case of rate limits.

      Sample log:

      === Attempt 1/3 ===
      [INFO] Using fresh TOTP: 085893
      [RESULT] {'status': False, 'message': 'Invalid totp', 'errorcode': 'AB1050', 'data': None}

      Could you please:

      Check on your server logs for my Client ID (S565246) for recent login attempts.

      Confirm if there is any new format, encoding, or configuration for the ANGEL_TOTP_SECRET.

      Let me know if there are any recent changes to the TOTP verification logic.

      Thank you,
      Swapnil Mahajan!Screenshot 2025-08-14 112420.jpg

      1 Reply Last reply Reply Quote 0
      • First post
        Last post