Navigation

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

    Getting Error on Smart API generateSession (Node JS)

    Bugs
    0
    2
    16
    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.
    • R
      RS last edited by

      import { totp } from 'otplib';
      import dotenv from 'dotenv';
      dotenv.config();

      const getTOTP = () => {
      try {
      const otp = totp.generate(ANGEL_ONE_TOTP_KEY);
      return otp;
      } catch (err) {
      console.log(err)
      }
      }

      const startWebSocketConnection = async () => {

      try {
          smartApi
              .generateSession(process.env.ANGEL_ONE_CLIENT_ID, process.env.ANGEL_ONE_CLIENT_SECRET, getTOTP())
              .then((data) => {
                  console.log(data);
                  return smartApi.getProfile();
              })
              .then((data) => {
                  console.log(JSON.stringify(data, null, 2));
              })
              .catch((error) => {
                  console.log(error);
              });
          
      } catch (err) {
          console.log(err)
      
      }
      

      };
      // _currentUrl: 'https://apiconnect.angelone.in/user_login'
      /* Getting the Following Error
      "<html><head><title>Request Rejected</title></head><body>The requested URL was rejected. Please consult with your administrator.<br><br>Your support ID is: 13563063868471547593<br><br><a href='javascript:history.back();'>[Go Back]</a></body></html>" */

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

        @RS please refer https://github.com/angel-one/smartapi-python/blob/main/SmartApi/smartApiWebsocket.py

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