# How to build custom MFA pages

**URL:** <https://community.auth0.com/t/how-to-build-custom-mfa-pages/104843>\
**Category:** Get Help\
**Tags:** mfa-api, mfa\
**Created:** [April 17, 2023, 8:04am UTC](https://community.auth0.com/t/how-to-build-custom-mfa-pages/104843 "2023-04-17T08:04:22Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeremie.poisson](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jeremie.poisson/32/33711_2.png) [@jeremie.poisson](https://community.auth0.com/u/jeremie.poisson)\
**Post date:** [April 17, 2023, 8:04am UTC](https://community.auth0.com/t/how-to-build-custom-mfa-pages/104843/1 "2023-04-17T08:04:22Z")

</div>

Hi,

We’re using the New Universal login for authentication and we want to use MFA Email and/or SMS.

Universal login doesn’t allow MFA email as a single factor, so we want to build a custom MFA page to do it ourselves by using MFA API.

The issue is that when we want to challenge a MFA factor we need a MFA\_TOKEN. This token only seems to be granted through ROPG flow. But we’re using universal login and not ROPG.

The documentation here is unclear to understand how to achieve this : [Manage Authentication Factors with Authentication API](https://auth0.com/docs/secure/multi-factor-authentication/manage-mfa-auth0-apis/manage-authenticator-factors-mfa-api#universal-login)

Thank you

---

<div class="post-metadata">

**Author:** ![SaqibHussain](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/saqibhussain/32/42924_2.png) [@SaqibHussain](https://community.auth0.com/u/SaqibHussain)\
**Post date:** [April 26, 2023, 10:21pm UTC](https://community.auth0.com/t/how-to-build-custom-mfa-pages/104843/4 "2023-04-26T22:21:12Z")

</div>

Hi @jeremie.poisson

Thanks for getting in touch with us at Auth0 Community.

It’s correct that the ROPG flow does give you the mfa\_token but you can still use Universal Login providing you use the correct audience and scopes when making the request as per [https://auth0.com/docs/secure/multi-factor-authentication/manage-mfa-auth0-apis/manage-authenticator-factors-mfa-api#universal-login](https://auth0.com/docs/secure/multi-factor-authentication/manage-mfa-auth0-apis/manage-authenticator-factors-mfa-api#universal-login) e.g. a login request may redirect to the /authorize endpoint with the following information:

```auto
https://{your_domain}/authorize?&
response_type=code&
client_id={your_client_id}& 
redirect_uri=http://jwt.io&
scope=enroll+read:authenticators&
audience=https://{your_domain}/mfa/&
state=STATE

```

This will produce a JWT access token that you should be able to use in the rest of the flow where mfaToken is referenced e.g for SMS or voice see the flow here [https://auth0.com/docs/secure/multi-factor-authentication/authenticate-using-ropg-flow-with-mfa/enroll-challenge-sms-voice-authenticators#enroll-with-sms-or-voice](https://auth0.com/docs/secure/multi-factor-authentication/authenticate-using-ropg-flow-with-mfa/enroll-challenge-sms-voice-authenticators#enroll-with-sms-or-voice)

Warm regards.

---

<div class="post-metadata">

**Author:** ![jeremie.poisson](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jeremie.poisson/32/33711_2.png) [@jeremie.poisson](https://community.auth0.com/u/jeremie.poisson)\
**Post date:** [April 27, 2023, 11:47am UTC](https://community.auth0.com/t/how-to-build-custom-mfa-pages/104843/5 "2023-04-27T11:47:04Z")

</div>

Hi,

Ok that’s interesting but we already specify an audience for one of our API.

And Auth0 doesn’t support multiple audiences

---

<div class="post-metadata">

**Author:** ![SaqibHussain](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/saqibhussain/32/42924_2.png) [@SaqibHussain](https://community.auth0.com/u/SaqibHussain)\
**Post date:** [April 27, 2023, 12:00pm UTC](https://community.auth0.com/t/how-to-build-custom-mfa-pages/104843/6 "2023-04-27T12:00:39Z")

</div>

@jeremie.poisson I believe you would have to send another /authorize request with a new audience see [https://community.auth0.com/t/how-to-specify-multiple-audiences-on-authorize-method/81072/6](https://community.auth0.com/t/how-to-specify-multiple-audiences-on-authorize-method/81072/6)

---

<div class="post-metadata">

**Author:** ![jeremie.poisson](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jeremie.poisson/32/33711_2.png) [@jeremie.poisson](https://community.auth0.com/u/jeremie.poisson)\
**Post date:** [April 27, 2023, 12:45pm UTC](https://community.auth0.com/t/how-to-build-custom-mfa-pages/104843/7 "2023-04-27T12:45:30Z")

</div>

So the flow will be something like :

- User goes to the app
- User hit “Login” button
- The user is redirect to Auth0 with an /authorize request with https://{your\_domain}/mfa/ audience
- The user enters login/password (Does it works ?)
- He gets redirected to our external MFA pages with Actions (How can we have a Access Token to use here if we didn’t complete the process) ?
- User verify/enroll MFA
- He gets redirected to the app
- The app send another /authorize request (another redirection?)

That’s unclear here for me

---

<div class="post-metadata">

**Author:** ![SaqibHussain](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/saqibhussain/32/42924_2.png) [@SaqibHussain](https://community.auth0.com/u/SaqibHussain)\
**Post date:** [April 27, 2023, 10:34pm UTC](https://community.auth0.com/t/how-to-build-custom-mfa-pages/104843/8 "2023-04-27T22:34:27Z")

</div>

Hi @jeremie.poisson

I expect the flow would be something as you describe.

Your fourth point yes it does work 🙂

When you get redirected to your external MFA pages you will receive a code as part of the redirection (providing authentication was successful). You’ll then have to use the code in a POST request to _/oauth/token_

This will produce an Access Token which you can use on the _/mfa/associate_ endpoint to enrol an MFA factor.

When the user is redirected to your app you send another /authorise with your API as the audience/API scopes, use prompt=none to make a silent auth request and a new Access Token will be returned without the user having to re-authenticate as they already did this for MFA and the server session should still be valid.

I hope this makes sense.

Warm regards.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [May 11, 2023, 10:35pm UTC](https://community.auth0.com/t/how-to-build-custom-mfa-pages/104843/9 "2023-05-11T22:35:25Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
