FusionAuth JavaScript Client

JavaScript Client Library

The JavaScript client library allows you to integrate FusionAuth with your JavaScript application.

Source Code:

Please note that if you will be using this client library in front end code such as a web browser you will not have a secure way to store an API key. You may optionally pass a value of null for the API key parameter and still make API requests that do not require an API key.

The following code assumes FusionAuth is running on http://localhost:9011 and uses an API key 6b87a398-39f2-4692-927b-13188a81a9a3, you will need to supply your own API key, and if you are not running FusionAuth locally, your host parameter may be different.

Here is an example of using the retrieveUserByEmail method to retrieve a User by an email address.

<html>
  <head>
    <script src="../lib/ClientResponse.js"></script>
    <script src="../lib/RESTClient.js"></script>
    <script src="../lib/FusionAuthClient.js"></script>
    <script>
      var client = new FusionAuthClient('6b87a398-39f2-4692-927b-13188a81a9a3', 'http://localhost:9011');
      function handleResponse (clientResponse) {
        console.info(JSON.stringify(clientResponse.successResponse.user, null, 2));
      }

      // Retrieve User by Email Address
      client.retrieveUserByEmail('user@example.com', handleResponse);
    </script>
  </head>
  <body>
    Super Awesome Application
  </body>
</html>