Navigation

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

    Unable to login using SmartAPI Javascript Library - Getting Invalid Token - AG8001

    Bugs
    3
    5
    61
    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.
    • N
      nisha last edited by nisha

      Code

      let { SmartAPI, WebSocket } = require("smartapi-javascript");
      
      let smart_api = new SmartAPI({
          api_key: appConfig.angel.marketApiKey,    // PROVIDE YOUR API KEY HERE"
      });
      
      smart_api.generateSession(appConfig.angel.clientId, appConfig.angel.clientPwd)
          .then((data: any) => {
              return smart_api.getProfile();
          })
          .then((data: any) => {
              // Profile details
              console.log(data);
          })
          .catch((ex: any) => {
              //Log error
              console.log(ex);
          })
      
          // TO HANDLE SESSION EXPIRY, USERS CAN PROVIDE A CUSTOM FUNCTION AS PARAMETER TO setSessionExpiryHook METHOD
          smart_api.setSessionExpiryHook(customSessionHook);
      
          function customSessionHook() {
              console.log("User loggedout");
              
              // NEW AUTHENTICATION CAN TAKE PLACE HERE
          }
      

      Error

      User loggedout
      {
        success: false,
        message: 'Invalid Token',
        errorCode: 'AG8001',
        data: ''
      }
      

      Client ID: N174188

      @admin

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

        @nisha said in Unable to login using SmartAPI Javascript Library - Getting Invalid Token - AG8001:

        N174188

        we have noticed your issue.Provide us your contact details to further assist you.

        J 1 Reply Last reply Reply Quote 0
        • J
          jigs1996 @admin last edited by

          @admin
          i have the same issue

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

            Hi @jigs1996 Have you migrated your account?

            J 1 Reply Last reply Reply Quote 0
            • J
              jigs1996 @admin last edited by jigs1996

              @admin Thanks it's working now after migration thanks

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