Navigation

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

    Invalid totp

    General Discussion
    0
    10
    62
    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.
    • N
      nishi21694 last edited by

      ee827313-eb2e-49ea-a9e9-b8dabff32649-image.png

      Code was working fine since last 4-5 months and suddenly started giving error of Invalid TOTP.

      When I crossed check TOTP with google authenticator , it is not matching with what I am getting through totp.now().

      Kindly guide.

      S G 2 Replies Last reply Reply Quote 0
      • S
        sen @nishi21694 last edited by

        @nishi21694 That's correct.

        The code id resulting AB1050 error.

        Seems like Angel Team making changes without testing them thoroughly.

        I 1 Reply Last reply Reply Quote 0
        • M
          Moderator_2 last edited by

          Hi @nishi21694

          Apologies for delayed response.
          TOTP functionality is working fine from our end. We recommend to use the PyOtp in python SDK, Kindly reverify with the below code snippet and let us know if the issue still occurs

          pip install pyotp

          import pyotp
          try:
              token = "Your QR value"
              totp = pyotp.TOTP(token).now()
          except Exception as e:
              logger.error("Invalid Token: The provided token is not valid.")
              raise e
          

          Thanks & Regards,
          SmartAPI team

          K 1 Reply Last reply Reply Quote -1
          • I
            iamrv9 @sen last edited by

            @sen im getting the same error,have you resolved it?

            M 1 Reply Last reply Reply Quote 1
            • M
              Moderator_1 @iamrv9 last edited by

              Hello @iamrv9,

              Please use the TOTP generate function shared by @Moderator_2 .

              Let us know if you still have any issues.

              Regards
              SmartAPI Team

              1 Reply Last reply Reply Quote -1
              • A
                asr.rajesh last edited by

                I am also getting the same issue. Could you please fix this ASAP ?

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

                M 1 Reply Last reply Reply Quote 0
                • M
                  Moderator_1 @asr.rajesh last edited by

                  @asr-rajesh How are you calling the TOTP in your code?
                  @Moderator_2 has shared a method for python. Please use a similar method for your SDK.

                  A 1 Reply Last reply Reply Quote 0
                  • G
                    ganeshpanpat @nishi21694 last edited by

                    @nishi21694 i am also facing same error

                    1 Reply Last reply Reply Quote 0
                    • A
                      asr.rajesh @Moderator_1 last edited by

                      @Moderator_1 Thanks for the response. Its working for me now.

                      1 Reply Last reply Reply Quote 0
                      • K
                        kondorpa @Moderator_2 last edited by

                        @Moderator_2 getting TOTP error again. Here is the code I am running. Anything changed in the code?

                        from SmartApi.smartConnect import SmartConnect  #or from SmartApi.smartConnect import SmartConnect
                        import pyotp
                        from logzero import logger
                        
                        with open("angelConfig.json", 'r') as f:
                            data = json.load(f)
                            api_key = data['api_key']
                            # username = data['username']
                            pwd = data['pwd']
                            clientID = data["clientID"]
                        smartConn = SmartConnect(api_key)
                        
                        try:
                            token = data['otp_token']
                            totp = pyotp.TOTP(token).now()
                        
                        except Exception as e:
                            logger.error("Invalid Token: The provided token is not valid.")
                            raise e
                        data = smartConn.generateSession("clientID", "pwd", "totp")
                        refreshToken = data['data']['refreshToken']
                        userProfile = smartConn.getProfile(refreshToken)
                        
                        payload = {
                            "mode": "FULL",
                            "exchangeTokens": {
                                "NSE": ["3045"]
                            }
                        }
                        MarketQuoteData = smartConn.getMarketData(payload)
                        
                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post