> ## Documentation Index
> Fetch the complete documentation index at: https://docs.authsignal.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Using Authsignal with Auth0

> Learn how to integrate Authsignal with Auth0 to add MFA to your login flow, using methods such as Authenticator App, SMS OTP, Email OTP, and Passkeys.

This guide will demonstrate how to integrate Authsignal with Auth0 by creating a [Custom Action for the Login / Post-Login trigger](https://auth0.com/docs/customize/actions/flows-and-triggers/login-flow#login-post-login).

The end result will be to allow users to complete an MFA challenge after they login with their username and password, redirecting them from the Auth0 Universal Login Page to Authsignal's [pre-built UI](/implementation-options/prebuilt-ui/overview).

The integration follows Auth0’s official guidelines for redirecting users after login to do custom MFA.
You can learn more here about how to [Redirect with Actions in Auth0](https://auth0.com/docs/customize/actions/flows-and-triggers/login-flow/redirect-with-actions).

## User flow

<Steps>
  <Step title="The user enters their username and password in the Auth0 Universal Login page">
    <Frame>
      <img src="https://mintcdn.com/authsignal-23/U9XmxdPe4AWAeEuC/images/docs/auth0/login.png?fit=max&auto=format&n=U9XmxdPe4AWAeEuC&q=85&s=f283b58984fcb01380a45e8072699304" alt="Auth0 login screen." className="w-400" width="1244" height="1546" data-path="images/docs/auth0/login.png" />
    </Frame>
  </Step>

  <Step title="The user is redirected to Authsignal's pre-built UI to complete an MFA challenge">
    <Frame>
      <img src="https://mintcdn.com/authsignal-23/U9XmxdPe4AWAeEuC/images/docs/auth0/challenge.png?fit=max&auto=format&n=U9XmxdPe4AWAeEuC&q=85&s=115e50473d57fffc9133109fe374aad1" alt="Pre-built UI challenge screen." width="1452" height="1260" data-path="images/docs/auth0/challenge.png" />
    </Frame>
  </Step>

  <Step title="The user is logged in if the challenge is completed successfully" />
</Steps>

## Integration steps

<Steps>
  <Step title="Create an action">
    In the Auth0 Dashboard, go to Actions → Library and select “Build Custom”. Then select the “Login / Post Login” trigger and give the action an appropriate name (for example “post-login-mfa”).

    <Frame>
      <img src="https://mintcdn.com/authsignal-23/U9XmxdPe4AWAeEuC/images/docs/auth0/create-action.png?fit=max&auto=format&n=U9XmxdPe4AWAeEuC&q=85&s=8f74c950d620334c4d0e7f74d4592946" alt="Screenshot of creating a custom action in Auth0" width="2224" height="1350" data-path="images/docs/auth0/create-action.png" />
    </Frame>
  </Step>

  <Step title="Add your secret">
    Now your action has been created, create a new secret called `AUTHSIGNAL_SECRET` and provide the value of your secret from the Api Keys section in the Authsignal Portal.

    <Frame>
      <img src="https://mintcdn.com/authsignal-23/U9XmxdPe4AWAeEuC/images/docs/auth0/define-secret.png?fit=max&auto=format&n=U9XmxdPe4AWAeEuC&q=85&s=e0edaeacb6e3d21e918848b37cecee45" alt="Screenshot of defining the AUTHSIGNAL_SECRET in Auth0" width="1874" height="864" data-path="images/docs/auth0/define-secret.png" />
    </Frame>
  </Step>

  <Step title="Add dependencies">
    Add the `@authsignal/node` dependency.

    <Frame>
      <img src="https://mintcdn.com/authsignal-23/U9XmxdPe4AWAeEuC/images/docs/auth0/add-dependency.png?fit=max&auto=format&n=U9XmxdPe4AWAeEuC&q=85&s=91c0376b2ea3bf5b4340440efba6c0f3" alt="Screenshot of adding the Authsignal Node SDK as a dependency in Auth0" width="1840" height="842" data-path="images/docs/auth0/add-dependency.png" />
    </Frame>
  </Step>

  <Step title="Add the action code">
    Add the following code snippet to the action.

    ```javascript theme={null}
    const { handleAuth0ExecutePostLogin, handleAuth0ContinuePostLogin } = require("@authsignal/node");

    exports.onExecutePostLogin = handleAuth0ExecutePostLogin;

    exports.onContinuePostLogin = handleAuth0ContinuePostLogin;
    ```

    If using a non-US region (e.g. AU or EU) you will need to override the API URL as follows:

    ```javascript theme={null}
    const { handleAuth0ExecutePostLogin, handleAuth0ContinuePostLogin } = require("@authsignal/node");

    const apiUrl = "https://eu.api.authsignal.com/v1";

    exports.onExecutePostLogin = async (event, api) => {
      await handleAuth0ExecutePostLogin(event, api, { apiUrl });
    };

    exports.onContinuePostLogin = async (event, api) => {
      await handleAuth0ContinuePostLogin(event, api, { apiUrl });
    };
    ```
  </Step>

  <Step title="Connect your action to the Login flow">
    Now connect your action in the Flows section of the Auth0 Dashboard by dragging it into the Login flow.

    <Frame>
      <img src="https://mintcdn.com/authsignal-23/U9XmxdPe4AWAeEuC/images/docs/auth0/connect-action.png?fit=max&auto=format&n=U9XmxdPe4AWAeEuC&q=85&s=6ca5794a4094f84e8b536620c5c042ee" alt="Auth0 login screen" width="2100" height="1174" data-path="images/docs/auth0/connect-action.png" />
    </Frame>
  </Step>

  <Step title="Configure the action in Authsignal">
    Once the previous steps have been completed, the next time the Auth0 action is run you will see an action appear in the Authsignal Portal called **“Auth0 Login”.** You will need to set the default outcome for this action to `Challenge` and save it.

    <Frame>
      <img src="https://mintcdn.com/authsignal-23/U9XmxdPe4AWAeEuC/images/docs/auth0/set-default-outcome.png?fit=max&auto=format&n=U9XmxdPe4AWAeEuC&q=85&s=253df3b3e65c75b3dcf7d841fc947ea7" alt="Screenshot of setting the default action outcome in Auth0" width="1258" height="530" data-path="images/docs/auth0/set-default-outcome.png" />
    </Frame>

    That’s it! You’ve done everything required to add MFA to your Auth0 login flow using Authsignal.
  </Step>
</Steps>

## Next steps

* [Refining the MFA experience](/integrations/auth0-refine-mfa)
* [Using an internal user ID](/integrations/auth0-internal-user-id)
