Navigation

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

    Issue with Totp

    Python SDK
    0
    8
    40
    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
      Satnam last edited by

      Hi Folk, i am a novice in coding and while trying to get login into the Angle one demat via Spyder, i am getting the below error, can anyone help me, please.
      [E 240421 17:17:50 smartConnect:243] Error occurred while making a POST request to https://apiconnect.angelbroking.com/rest/auth/angelbroking/user/v1/loginByPassword. Error: Invalid totp. URL: https://apiconnect.angelbroking.com/rest/auth/angelbroking/user/v1/loginByPassword, Headers: {'Content-type': 'application/json', 'X-ClientLocalIP': '127.0.0.1', 'X-ClientPublicIP': '106.193.147.98', 'X-MACAddress': 'cc:48:3a:66:10:f5', 'Accept': 'application/json', 'X-PrivateKey': 'key_secret[0]', 'X-UserType': 'USER', 'X-SourceID': 'WEB'}, Request: {'clientcode': 'key_secret[2]', 'password': 'key_secret[3]', 'totp': '527069'}, Response: {'status': False, 'message': 'Invalid totp', 'errorcode': 'AB1050', 'data': None}
      [E 240421 17:17:50 temp:27] {'status': False, 'message': 'Invalid totp', 'errorcode': 'AB1050', 'data': None}

      M C M 3 Replies Last reply Reply Quote 0
      • M
        mxt448 @Satnam last edited by

        @Satnam Same here, Response: {'status': False, 'message': 'Invalid totp', 'errorcode': 'AB1050', 'data': None}

        J 1 Reply Last reply Reply Quote 0
        • C
          chetansuri @Satnam last edited by

          @Satnam are you using correct to pass onto totp code. it is simple 2 lines of code to get totp. are you using barcode id in totp. it would be around 26 words like "P1234ABC...." or similar.

          import pyotp

          totp= 'P123ABC' # Replace with your actual key
          totp.now()

          you can then pass on this totp.now() in angel one to work further. this exactly what I use

          M 1 Reply Last reply Reply Quote 0
          • M
            mxt448 @chetansuri last edited by

            @chetansuri Here is my code snippet
            a9416bb4-d800-4d07-af29-f0dad1151a4f-image.png

            1 Reply Last reply Reply Quote 0
            • J
              johngeorge @mxt448 last edited by

              @mxt448 same here and totp is right i checked that. my doubts are that it more kind of a problem while establishing the connection.

              1 Reply Last reply Reply Quote 0
              • M
                Moderator_3 @Satnam last edited by

                Hello @Satnam
                Please use your totp key which is generated and is this usually placed below the QR code and use this method to include totp

                from SmartApi import SmartConnect 
                import pyotp
                from logzero 
                import logger
                api_key = 'yourAPIKey'
                username = 'YourClientCode'
                pwd = 'YourPIN'
                smartApi = SmartConnect(api_key)
                try:
                    token = "TOTP_String"
                    totp = pyotp.TOTP(token).now()
                except Exception as e:
                    logger.error("Invalid Token: The provided token is not valid.")
                    raise e
                correlation_id = "abcde"
                

                Regards,
                SmartAPI Team
                data = smartApi.generateSession(username, pwd, totp)

                J 1 Reply Last reply Reply Quote 0
                • J
                  johngeorge @Moderator_3 last edited by

                  @Moderator_3 Still it
                  does not work

                  M 1 Reply Last reply Reply Quote 0
                  • M
                    Moderator_3 @johngeorge last edited by

                    Hello @johngeorge
                    please use this code in your code to use a totp functionality

                    Screenshot 2024-05-07 at 5.10.38 PM.png
                    Regards,
                    SmartAPI Team

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