Navigation

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

    AB1050 Invalid TOTP while connect.GenerateSession

    C#/.Net SDK
    0
    16
    106
    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
      sen last edited by

      You are supposed to use any OTP library.

      1. Do you have the QR code for TOTP?
      2. Add OTPNet nuget in your project. (OTPNet)
      3. Convert TOTP QR to OTP string.

      //Initialize Samart API using clientcode and password to test the code.
      string totp = "2EYUVJNXYERUXPLAATDRTUHSWM";
      string Client_code = "DELL2456"; //YOUR CLIENT CODE
      string Password = "3456"; //YOUR PASSWORD
      string api_key = "OvPZUMMM";
      string JWTToken = ""; // optional
      string RefreshToken = ""; // optional

      SmartApi connect = new SmartApi(api_key, JWTToken, RefreshToken);
      OutputBaseClass obj = new OutputBaseClass();

      //Login by client code and password
      obj = connect.GenerateSession(Client_code, Password, totp);

      ------Next in SmartConnetClass
      /User Calls/
      public OutputBaseClass GenerateSession(string clientcode, string password, string totpString)
      {
      OutputBaseClass res = new OutputBaseClass();
      byte[] secretBytes = Base32Encoding.ToBytes(totpString);

       **// Create an instance of the TOTP class
       var totp = new Totp(secretBytes);
      
       // Get the current TOTP code
       string totpCode = totp.ComputeTotp();**
       res.status = true;
       res.http_code = "200";
       try
       {
           AngelTokenResponse agr = new AngelTokenResponse();
      
           string URL = APIURL + "/rest/auth/angelbroking/user/v1/loginByPassword";
      
           string PostData = "{\"clientcode\":\"" + clientcode + "\",\"password\":\"" + password + "\",\"totp\":\"" + **totpCode** + "\"}";
      

      If required, let me know, I can push entire code to GitHub

      S 1 Reply Last reply Reply Quote 0
      • F
        fcoder last edited by

        I have revamped c# sdk version and have uploaded it to below link. This version works with totp. Here is the link :https://github.com/piyush-r-pub/SmartAPI_AO. How to use it: https://github.com/piyush-r-pub/SmartAPI_AO/wiki. Please let me know if you face any issues or need any help.

        N A 2 Replies Last reply Reply Quote 1
        • N
          nitinshinde75 @fcoder last edited by

          @fcoder Thanks.

          I have followed your code.. and now I am facing issue with http code: AB1006 - Client is block for trading.

          61811473-4482-4d75-a7ed-410279d76b72-image.png

          1 Reply Last reply Reply Quote 0
          • V
            Vishal.naykawala @PVRavindran last edited by

            @PVRavindran I can provide you with the updated DLL. That change I made in DLL.

            V N 3 Replies Last reply Reply Quote 1
            • N
              nitinshinde75 @Vishal.naykawala last edited by

              @Vishal-naykawala Please provide me the latest one dll

              1 Reply Last reply Reply Quote 0
              • N
                nitinshinde75 @Vishal.naykawala last edited by

                @Vishal-naykawala said in AB1050 Invalid TOTP while connect.GenerateSession:

                @PVRavindran I can provide you with the updated DLL. That change I made in DLL.

                Please share..

                1 Reply Last reply Reply Quote 0
                • V
                  Vishal.naykawala @Vishal.naykawala last edited by

                  @Vishal-naykawala How can I give you?

                  share your mail id.

                  N 2 Replies Last reply Reply Quote 0
                  • N
                    nitinshinde75 @Vishal.naykawala last edited by

                    @Vishal-naykawala said in AB1050 Invalid TOTP while connect.GenerateSession:

                    ur mail id.

                    nitinshinde75@gmail.com

                    1 Reply Last reply Reply Quote 0
                    • N
                      nitinshinde75 @Vishal.naykawala last edited by

                      @Vishal-naykawala said in AB1050 Invalid TOTP while connect.GenerateSession:

                      are your mail

                      my userid at gmail . com

                      1 Reply Last reply Reply Quote 0
                      • A
                        amrutjk @fcoder last edited by amrutjk

                        @fcoder Thanks for the library. I am facing the same issue ..."Client is blocked for trading". I am able to trade normally(manually) and also using another library, able to connect to my account.erroe.png

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

                          Hello @amrutjk
                          Can you please drop a mail to smartapi@angelbroking.com with your concern

                          Regards,
                          SmartAPI Team

                          A 1 Reply Last reply Reply Quote 0
                          • A
                            amrutjk @Moderator_3 last edited by

                            @Moderator_3 Never mind...sorted out the issue as it was with the code but the error pointed in different direction.

                            1 Reply Last reply Reply Quote 0
                            • S
                              Sdk @sen last edited by

                              @sen said in AB1050 Invalid TOTP while connect.GenerateSession:

                              QR to OTP string.

                              Could you please push the entire code on GitHub

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