Your app redirects to a web page hosted by Authsignal (or displays it modally in an iframe). This is often the quickest way to integrate. You can configure your own custom domain and you can heavily customize the look and feel.

1. Backend - Track action

In your app’s backend, track an action which represents what your user is doing, e.g. signIn. You can do this using one of the Authsignal Server SDKs or you can call the Authsignal Server API directly using a RESTful HTTP request.

const result = await authsignal.track({
  userId: user.id,
  action: "login",
  redirectUrl: "https://yourapp.com/callback",
});

const url = result.url;

2. Frontend - Launch the pre-built UI

In your app’s frontend, pass the url from the track call to the Authsignal Web SDK to launch an enrollment or re-authentication flow.

authsignal.launch(url);

Alternatively you can handle displaying the pre-built UI (via redirect or modal) yourself for this step - using the Authsignal Web SDK is optional.

3. Backend - Validate challenge

Once the user has completed the challenge, Authsignal will send them back to the redirect URL you provided in step 1, appending a token as a query param which you can use to determine the result of the challenge server-side.

const { state } = await authsignal.validateChallenge({ token: resultToken });

if (state === "CHALLENGE_SUCCEEDED") {
  // The user completed the challenge successfully
  // Proceed with authenticated action or integrate with IdP to create authenticated session
} else {
  // The user did not complete the challenge successfully
}

Next steps