Navigation

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

    java sdk TOTP

    General Discussion
    4
    8
    17
    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.
    • M
      malhar1080p last edited by

      I am trying to login in to angel one smart api via v2.0.0 jar but unable to login due invalid totp eventhough i have extensivel checked and it is correct.
      login result: {"data":null,"message":"Invalid totp","errorcode":"AB1050","status":false
      any java developer who is currently working on maven or java pls help

      V 1 Reply Last reply Reply Quote 0
      • A
        admin last edited by

        Hi @malhar1080p

        Please share us your json request body here to verify.

        1 Reply Last reply Reply Quote 0
        • V
          vaishali kale @malhar1080p last edited by

          @malhar1080p

          1 Reply Last reply Reply Quote 0
          • 9
            9868072301 last edited by

            I am also facing same issue but in nodejs

            here is my code
            async function login2(userId, password, totp1 = "") {
            // Get API credentials for this user
            const user = await userService.getUser("angelone", userId);
            if (!user) {
            throw new Error("User not found or not subscribed");
            }

            const apiKey = user["api_key"];
            const apiSecret = user["api_secret"];

            let { SmartAPI } = require("smartapi-javascript");

            const totp = speakeasy.totp({
            secret: TOTP_SECRET,
            encoding: "base32",
            });

            console.log("%s", [apiKey, userId, password, totp]);

            let smart_api = new SmartAPI({
            api_key: apiKey, // PROVIDE YOUR API KEY HERE
            });

            // If user does not have valid access token and refresh token then use generateSession method
            res = await smart_api.generateSession(userId, password, totp);
            console.log(res);
            return res;
            }

            here is response
            {
            status: false,
            message: 'Invalid totp',
            errorcode: 'AB1050',
            data: null
            }

            Book flight with Travomojo and get Instant 30% OFF on Domestic & international flights. Call 1-844-902-2949 us and grab the best flight booking deal.

            1 Reply Last reply Reply Quote 0
            • A
              admin last edited by

              Hi @9868072301 @malhar1080p

              Please do check are you passing appropriate 6 digit TOTP code from authenticator app.

              9 1 Reply Last reply Reply Quote 0
              • 9
                9868072301 @admin last edited by

                @admin Yes i did checked i am passing correct 6 digit code from authenticator app and also it is matching with speakeasy's totp function response

                Book flight with Travomojo and get Instant 30% OFF on Domestic & international flights. Call 1-844-902-2949 us and grab the best flight booking deal.

                1 Reply Last reply Reply Quote 0
                • A
                  admin last edited by

                  Hi @9868072301

                  Are you passing 4 digit pin in password parameter ?

                  9 1 Reply Last reply Reply Quote 0
                  • 9
                    9868072301 @admin last edited by

                    @admin Yes I do, also verified it by printing it in console you can see below line in my code

                    console.log("%s", [apiKey, userId, password, totp]);

                    Book flight with Travomojo and get Instant 30% OFF on Domestic & international flights. Call 1-844-902-2949 us and grab the best flight booking deal.

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