frontend-js
Frontend package to help accelerate authillo integration for javascript (or typescript) based frontends
Initialization
-
Create Your platform
-
Install the npm package by running the following command Install @authillo/frontend-js
npm i @authillo/frontend-js
-
We recommend that you import Authillo at the beginning of your frontend javascript code execution (you'll likely call this function in an index.(some-file-extension) file ) Import the Authillo package
import { Authillo } from "@authillo/frontend-js";
-
Initialize your Authillo instance with your platform’s configuration by calling the initialize function as outlined below Initialize Authillo Instance
Authillo.initialize({ clientId: "your_client_id", defaultRedirectUri: "your_default_redirect_uri", });
Login or Verify a user
-
Initialize your instance
Ensure you've completed all the tasks in the initialization steps above
-
Perform Authorization Request
Perform the Authorization Request by calling the
Authillo.begin()
function with the relevant information you’d like the user to verify. During the Authorization request, the user will be redirected to authillo’s website to perform the relevant verificationsAuthillo.begin(["face"]);
-
Handle User Returning
We then redirect the user back to your site at the
redirect_uri
that you provided during the Authorization Request step (or to thedefaultRedirectUri
that you specified duringAuthillo.initialize()
)-
In this step, you’ll want to grab the authorizationCode and state parameters from the querystring parameters. For convenience, we’ve created a utility function that parses the parameters for you and returns them as a javascript object
-
const { code, state } = Authillo.parseResultsFromQueryString();
-
-
Perform Token Request
- Send a request from your frontend to your backend that includes the following information
- the authorizationCode (stored in the
code
variable in the above code snippet) - the state (stored in the
state
variable in the above code snippet)
- the authorizationCode (stored in the
- In your backend, perform the token request as outlined in authillo’s documentation
- Send a request from your frontend to your backend that includes the following information
-
Perform User Info Request
- Once you’ve received tokens, you can perform a userInfo request as outlined in authillo’s documentation
-
Return JWT
- Return the user’s ID token to the frontend