How to get/show rules error messages in auth0-react-samples app


I am using auth0-react-samples and more specifically 02-Calling-an-API example code. I have it working for success scenarios and returns JWT which works with my API.

Problem: I have some rules that check for some values and based on that return a UnauthorizedError

return callback(new UnauthorizedError(
‘User has no profiles for this application.’

How do I get this error in SPA and show it to user?
I saw but shouldn’t auth0FromHook.handleRedirectCallback() handle it and return error obj or something.

I found React Quickstart can't parse token in handleRedirectCallback but their solution of deleting the rule don’t work for us. We want the error message so use knows they are not allowed.
Also do I have to explicitly logout this user from app, if rules failed or it happens on auth0 end?


1 Like

I am working on this very issue right now. Did you ever figure that out?

Nope. We are planning to either do a MFA enrollment separate via the enrollment email or moving the error logic to application callback page.