Navigation

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

    Getting Invalid TOTP/Token error in generateSession method call

    Bugs
    0
    2
    6
    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.
    • B
      brajalal last edited by

      Here are my code:

      require("dotenv").config();
      let { SmartAPI } = require("../lib");

      const API_KEY = process.env.API_KEY;
      const CLIENT_CODE = process.env.CLIENT_ID;
      const PASSWORD = process.env.PASSWORD;
      const TOTP = process.env.TOTP;

      let smart_api = new SmartAPI({
      api_key: API_KEY,
      });

      smart_api
      .generateSession(CLIENT_CODE, PASSWORD, TOTP)
      .then((data) => {
      console.log(data);
      return smart_api.getProfile();
      })
      .then((data) => {
      console.log(JSON.stringify(data, null, 2));
      })
      .catch((error) => {
      console.log(error);
      });

      Getting following response:
      {
      status: false,
      message: 'Invalid totp',
      errorcode: 'AB1050',
      data: null
      }
      {
      "success": false,
      "message": "Invalid Token",
      "errorCode": "AG8001",
      "data": ""
      }

      @admin Could you please help?

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

        @brajalal

        TOTP expires within a minute.
        Storing a TOTP in env variable will not work

        Regards,
        SmartAPI Team

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