# Challenge MFA endpoint always returns unauthorized

**URL:** <https://community.auth0.com/t/challenge-mfa-endpoint-always-returns-unauthorized/95506>\
**Category:** Get Help\
**Tags:** mfa-api, mfa\
**Created:** [December 1, 2022, 5:57pm UTC](https://community.auth0.com/t/challenge-mfa-endpoint-always-returns-unauthorized/95506 "2022-12-01T17:57:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kaspbrakk](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/kaspbrakk/32/33596_2.png) [@kaspbrakk](https://community.auth0.com/u/kaspbrakk)\
**Post date:** [December 1, 2022, 5:57pm UTC](https://community.auth0.com/t/challenge-mfa-endpoint-always-returns-unauthorized/95506/1 "2022-12-01T17:57:02Z")

</div>

I have been trying to implement OTP MFA as described in this page here: [Enroll and Challenge OTP Authenticators](https://auth0.com/docs/secure/multi-factor-authentication/authenticate-using-ropg-flow-with-mfa/enroll-and-challenge-otp-authenticators#challenge-user-with-otp)

And it works fine up until I have to make the request to `/mfa/challenge`. No matter what I do, I always receive a server error that only says “Unauthorized”. I’ve seen other posts in the forums saying to add the **'Content-Type: application/json’** header, and I’ve done that, and it doesn’t solve the issue for me.

I’m doing this in a trial account with PRO MFA enabled. I would really appreciate any help with this. Thanks!

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [December 2, 2022, 1:46am UTC](https://community.auth0.com/t/challenge-mfa-endpoint-always-returns-unauthorized/95506/3 "2022-12-02T01:46:35Z")

</div>

Hey there @kaspbrakk welcome to the community!

> [@kaspbrakk](#):
>
> And it works fine up until I have to make the request to `/mfa/challenge`. No matter what I do, I always receive a server error that only says “Unauthorized”. I’ve seen other posts in the forums saying to add the **'Content-Type: application/json’** header, and I’ve done that, and it doesn’t solve the issue for me.

Sorry to hear this isn’t working for you 🤔 It seems trivial but I’d double check all the `data` input to start - I believe MFA tokens have short lifetime (5 minutes) or less, are you making the calls in quick succession?

If you’d like share the specific calls you are making (redacted of course) that might be of help as well 🙂 I just ran through this using curl and all seemed to be functioning as expected.

Let us know!

---

<div class="post-metadata">

**Author:** ![kaspbrakk](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/kaspbrakk/32/33596_2.png) [@kaspbrakk](https://community.auth0.com/u/kaspbrakk)\
**Post date:** [December 2, 2022, 3:23pm UTC](https://community.auth0.com/t/challenge-mfa-endpoint-always-returns-unauthorized/95506/4 "2022-12-02T15:23:52Z")

</div>

Hi @ty.frith, thank you very much for replying. Here is all the information around the requests I’m making:

1 - I’m making a POST request to `oauth/token`, with `grant_type=password`, using the ClientId and ClientSecret of a regular web application with the Password and MFA grants enabled. This throws an error with the mfa\_token included, as expected.  
2 - I’m making a GET request to `mfa/authenticators` using the mfa\_token as the authorization header to get the OTP authenticator I want. This also works correctly.  
3 - I’m making a POST request to `mfa/challenge` using the authenticator Id I just got in the last request, the same mfa\_token, the same client id I used in the first request, and challenge type set to “otp”. This is the step that doesn’t work and just say “Unauthorized”. Same thing happens if I add the **'Content-Type: application/json’**.

I’ve tried doing this via code and via postman, the result is the same. With minimal interval between requests too, so I don’t think the lifetime of the mfa\_token would be the issue.

My only guess as to what could be happening is that the MFA api is not working with a trial account for some reason, even if it has PRO MFA.

Really appreciate the help!

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [December 3, 2022, 12:06am UTC](https://community.auth0.com/t/challenge-mfa-endpoint-always-returns-unauthorized/95506/5 "2022-12-03T00:06:12Z")

</div>

Hey @kaspbrakk no problem, happy to help where I can!

> [@kaspbrakk](#):
>
> I’ve tried doing this via code and via postman, the result is the same. With minimal interval between requests too, so I don’t think the lifetime of the mfa\_token would be the issue.
> 
> My only guess as to what could be happening is that the MFA api is not working with a trial account for some reason, even if it has PRO MFA.

Thanks for confirming - Everything seems to line up and OTP _should_ work with Pro MFA so I’m not sure the snag with `/mfa/challenge`. Have you tried creating a new app to test against? If you want to DM me your tenant and let me know the ID both the new app and old app you are testing against I’d be happy to take a look on our end to see if there is anything that might stand out as being a potential issue.

Let me know!

---

<div class="post-metadata">

**Author:** ![kaspbrakk](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/kaspbrakk/32/33596_2.png) [@kaspbrakk](https://community.auth0.com/u/kaspbrakk)\
**Post date:** [December 7, 2022, 2:45pm UTC](https://community.auth0.com/t/challenge-mfa-endpoint-always-returns-unauthorized/95506/6 "2022-12-07T14:45:19Z")

</div>

Leaving this comment in case anyone has the same problem in the future:

@ty.frith helped me identify I was missing the `client_secret` property in the request. The documentation didn’t mention it, but the challenge endpoint doesn’t seem to work without it.

![image](https://global.discourse-cdn.com/auth0/original/3X/2/a/2ad9ddb10540a144bc1035f160174239a5e3893e.png)

Thank you very much for your time and help @ty.frith!

---

<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:** [December 22, 2022, 12:26am UTC](https://community.auth0.com/t/challenge-mfa-endpoint-always-returns-unauthorized/95506/7 "2022-12-22T00:26:43Z")

</div>

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