Invalid state error returned instead of unauthorized error
- SDK Version: 1.10.1
- React Platform Version:17.0.0
When getting this redirect that that I set up with rules I get "invalid state" as the error instead of the actual error returned.
The redirected URL:
http://
in const { isAuthenticated, error, logout } = useAuth0() the error is invalid state instead of the expected unauthorized.
Hi @weisssean - thanks for raising this
This is expected behaviour, the client checks for the state (to confirm that the login was initiated from the application) before asserting any errors from the AS here
Which makes sense, since if the client can't establish that the login started from the app, then it can't confirm that the messages from the server are for it
So how do I get and show the correct error to the user? scrape it from the URL? seems broken to me.

Are you hitting that URL as part of a login flow? If so, then your login flow is broken, because the SDK cannot pick up the state cookie to verify the callback request.
If you're just hitting that URL out of the context of a login flow, then I don't see why you want to show that message to the user. You're just creating a route that shows the user whatever you put in the error parameter.
OK, my issue was just that I had an error already in the url and I refresh the page. Instead of that error being in the useAuth0 ().error, it returns that "invalid state" error. Not the expected behavior but I can live with that.
Thank you @adamjmcgrath