Navigation

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

    Smart API Login issue

    Test
    0
    15
    90
    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
      shreyas2290 last edited by

      I have written a code to login. I am getting status code as 200. However, I am not getting the response in the format mentioned in the documentation.

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

        Hello @shreyas2290

        Can you please provide which API you are using for the same

        Regards,
        SmartAPI Team

        S S 3 Replies Last reply Reply Quote 0
        • S
          shreyas2290 @Moderator_3 last edited by

          @Moderator_3
          I am using trading api

          1 Reply Last reply Reply Quote 0
          • S
            shreyas2290 @Moderator_3 last edited by

            @Moderator_3

            Following is the code. I have entered IP address, public IP address, mac address, client id, pin, API key and totp correctly. Still I am getting error. The following code is from API Documentation. I have pasted the error in the end.

            import http.client
            import mimetypes
            conn = http.client.HTTPSConnection(
            "apiconnect.angelbroking.com"
            )
            payload = "{\n"clientcode":"CLIENT_ID"
            ,\n"password":"CLIENT_PIN"\n
            ,\n"totp":"TOTP_CODE"\n}"
            headers = {
            'Content-Type': 'application/json',
            'Accept': 'application/json',
            'X-UserType': 'USER',
            'X-SourceID': 'WEB',
            'X-ClientLocalIP': 'CLIENT_LOCAL_IP',
            'X-ClientPublicIP': 'CLIENT_PUBLIC_IP',
            'X-MACAddress': 'MAC_ADDRESS',
            'X-PrivateKey': 'API_KEY'
            }
            conn.request(
            "POST", "/rest/auth/angelbroking/user/v1/loginByPassword", payload, headers)

            res = conn.getresponse()
            data = res.read()
            print(data.decode("utf-8"))

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

            1 Reply Last reply Reply Quote 0
            • S
              sunil_modi @Moderator_3 last edited by

              @Moderator_3 I am not able to enable totp from ui and when i try to generate it using secret key i am getting Error: Invalid totp.

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

                Hello @sunil_modi

                Can you please use this pyotp library
                totp = pyotp.TOTP(token).now()
                https://pypi.org/project/pyotp/

                Regards,
                SmartAPI Team

                S 2 Replies Last reply Reply Quote 0
                • S
                  sunil_modi @Moderator_3 last edited by

                  @Moderator_3 This is what i am doing, still getting same error

                  secret_key = "f6f7faf4-7986-45-be2f-751f890b9be2"

                  base32_secret = base64.b32encode(secret_key.encode()).decode()

                  Generate a TOTP instance

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

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

                    @Moderator_3 i am doing the same still getting this error

                    secret_key = "f6f7faf4-7986-45-be2f-751f890b9be2"

                    base32_secret = base64.b32encode(secret_key.encode()).decode()

                    totp = pyotp.TOTP(base32_secret)

                    obj = SmartConnect(api_key=api_key)

                    data = obj.generateSession(client_id, '5437', totp.now())

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

                      Home @sunil_modi

                      Can you please don't encode the string which you are getting from the totp screen.Instead of encoding please pass it directly

                      Regards,
                      SmartAPI Team

                      S 3 Replies Last reply Reply Quote 0
                      • S
                        sunil_modi @Moderator_3 last edited by

                        @Moderator_3 if i directly pass the secret key it is giving error like
                        1615dc9b-a2d2-4a34-8878-34c304a544d3-image.png

                        M 1 Reply Last reply Reply Quote 0
                        • J
                          jdx last edited by

                          Hi,
                          Can you please solve this issue.

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

                          1 Reply Last reply Reply Quote 0
                          • S
                            sunil_modi @Moderator_3 last edited by

                            @Moderator_3 i got this error when i don't encode
                            6c1958dd-6c7a-4d15-af28-fff3f2ad5b07-image.png

                            when i simply pass secret key i got this error

                            95b15e84-5b75-4fdd-ae56-27606289c682-image.png

                            would you please give me connection code

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

                              Hello @sunil_modi

                              I can see still you are passing the encoded secret_key while calling the pyotp.please check and confirm the same

                              Regards,
                              SmartAPI Team

                              1 Reply Last reply Reply Quote 0
                              • S
                                sunil_modi @Moderator_3 last edited by

                                @Moderator_3 i am not able to login to totp screen. Everytime i try to login using mpin i am getting this error
                                29e42663-c3a6-48e3-abcc-a62ccd49fb69-image.png

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

                                  @sunil_modi are you passing your mobile MPIN in the password field? Please pass that here. We are working to change this nomenclature here.

                                  Also, the secret key for TOTP is not the secret key generated along with the API key in the app. The string which you need to pass in the TOTP is the one generated below the QR code in TOTP Generation.

                                  Screenshot 2024-02-12 at 1.27.05 PM.png

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