# How to allow user to enroll MFA any time inside an application

**URL:** <https://community.auth0.com/t/how-to-allow-user-to-enroll-mfa-any-time-inside-an-application/165517>\
**Category:** Get Help\
**Tags:** guardian, management-api\
**Created:** [December 23, 2024, 9:08pm UTC](https://community.auth0.com/t/how-to-allow-user-to-enroll-mfa-any-time-inside-an-application/165517 "2024-12-23T21:08:37Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jai1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jai1/32/59979_2.png) [@jai1](https://community.auth0.com/u/jai1)\
**Post date:** [December 23, 2024, 9:08pm UTC](https://community.auth0.com/t/how-to-allow-user-to-enroll-mfa-any-time-inside-an-application/165517/1 "2024-12-23T21:08:37Z")

</div>

Hi,

we are migrating MFA to Auth0. In our current application, we have a menu option which allow user to enroll MFA any time while they are in the application. But it doesn’t seem Auth0 provide a way to do it.  
we have tried to use API to get enrollment URL with a ticket, but we can’t display this enrollment page in our application, Auth0 forbid using iframe. If we display the URL on the page, after enrollment, there is no way to go back to our application.

We have also tried to force user to go through post login action without the need to login again, but couldn’t make this work.

Any help is greatly appreciated.

Thanks!  
jai

---

<div class="post-metadata">

**Author:** ![sumansaurav](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sumansaurav/32/70627_2.png) [@sumansaurav](https://community.auth0.com/u/sumansaurav)\
**Post date:** [December 23, 2024, 9:27pm UTC](https://community.auth0.com/t/how-to-allow-user-to-enroll-mfa-any-time-inside-an-application/165517/2 "2024-12-23T21:27:18Z")

</div>

Hi @jai1,

If you want to enroll user into MFA at any moment. You can refer below documentation:

Step 1. Get MFA access token:

[https://auth0.com/docs/secure/multi-factor-authentication/manage-mfa-auth0-apis/manage-authenticator-factors-mfa-api](https://auth0.com/docs/secure/multi-factor-authentication/manage-mfa-auth0-apis/manage-authenticator-factors-mfa-api)

Step 2. Enroll authenticator - SMS, Phone, TOTP

[https://auth0.com/docs/secure/multi-factor-authentication/authenticate-using-ropg-flow-with-mfa/enroll-and-challenge-otp-authenticators](https://auth0.com/docs/secure/multi-factor-authentication/authenticate-using-ropg-flow-with-mfa/enroll-and-challenge-otp-authenticators)

Note: post-login action is best way to force enroll user into MFA.

[https://auth0.com/docs/secure/multi-factor-authentication/adaptive-mfa/customize-adaptive-mfa](https://auth0.com/docs/secure/multi-factor-authentication/adaptive-mfa/customize-adaptive-mfa)

---

<div class="post-metadata">

**Author:** ![jai1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jai1/32/59979_2.png) [@jai1](https://community.auth0.com/u/jai1)\
**Post date:** [December 23, 2024, 10:56pm UTC](https://community.auth0.com/t/how-to-allow-user-to-enroll-mfa-any-time-inside-an-application/165517/3 "2024-12-23T22:56:20Z")

</div>

Thanks Suman for the quick response. with your approach, we need to build our own UI to allow user to select what factor to enroll, correct?

we want to use Auth0 enrollment page instead, is that doable? by using POST /api/v2/guardian/enrollments/ticket, we can get a URL back, we want to display this URL in our iframe or module window, but we can’t make it work because Auth0 doesn’t allow it.

---

<div class="post-metadata">

**Author:** ![sumansaurav](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sumansaurav/32/70627_2.png) [@sumansaurav](https://community.auth0.com/u/sumansaurav)\
**Post date:** [December 23, 2024, 11:34pm UTC](https://community.auth0.com/t/how-to-allow-user-to-enroll-mfa-any-time-inside-an-application/165517/4 "2024-12-23T23:34:05Z")

</div>

Yes, you need to build your own UI.

I would never recommend using Iframe or module window because, there are several security and user experience concerns to consider:

1. Security Risks:

- Authentication pages in iframes are vulnerable to clickjacking attacks
- It’s harder to verify the authenticity of the page within an iframe
- Many authentication providers (including Auth0) explicitly block iframe embedding through X-Frame-Options headers for security reasons

1. Browser Compatibility:

- Modern browsers are increasingly restrictive with iframe-based authentication due to security policies
- Pop-up blockers often interfere with module windows

Instead, Build a Native Experience:

- Create your own enrollment UI that directly integrates with Auth0’s APIs
- This gives you full control over the user experience while maintaining security
- You can style it to match your application perfectly

Hope this helps.

---

<div class="post-metadata">

**Author:** ![sumansaurav](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sumansaurav/32/70627_2.png) [@sumansaurav](https://community.auth0.com/u/sumansaurav)\
**Post date:** [December 23, 2024, 11:39pm UTC](https://community.auth0.com/t/how-to-allow-user-to-enroll-mfa-any-time-inside-an-application/165517/5 "2024-12-23T23:39:52Z")

</div>

You could also use redirect.

```auto
// Instead of iframe/popup:
window.location.href = enrollmentUrl;

// Handle the return with a callback URL
// Auth0 will redirect back to your application

```

---

<div class="post-metadata">

**Author:** ![jai1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jai1/32/59979_2.png) [@jai1](https://community.auth0.com/u/jai1)\
**Post date:** [December 31, 2024, 4:05pm UTC](https://community.auth0.com/t/how-to-allow-user-to-enroll-mfa-any-time-inside-an-application/165517/6 "2024-12-31T16:05:15Z")

</div>

Hi Suman,

we went ahead and tried to build our own UI, but we need to get MFA access token, but this token seems can only be retrieved using user id and password. We don’t have the password after user already completed the login process. We also tried to use MFA Audience, but this requires all users to enroll MFA during login process which we don’t want.

Is there anything we do wrong?

Thanks.  
Jai

---

<div class="post-metadata">

**Author:** ![sumansaurav](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sumansaurav/32/70627_2.png) [@sumansaurav](https://community.auth0.com/u/sumansaurav)\
**Post date:** [January 6, 2025, 3:38am UTC](https://community.auth0.com/t/how-to-allow-user-to-enroll-mfa-any-time-inside-an-application/165517/7 "2025-01-06T03:38:34Z")

</div>

Sorry for delayed response. I was out of town. I am gonna look at this and get back to you in couple of days.

---

<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:** [January 20, 2025, 3:38am UTC](https://community.auth0.com/t/how-to-allow-user-to-enroll-mfa-any-time-inside-an-application/165517/8 "2025-01-20T03:38:53Z")

</div>

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