Getting Error on Smart API generateSession (Node JS)


  • 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>" */