How to Customize Error Message Returned to Application Callback Endpoint

Problem statement

When a user has been blocked via the Auth0 dashboard, the message is returned to the application’s callback endpoint with the error description in the URL:

https://yourdomain/callback?error=unauthorized&error_description=user%20is%20blocked&state=state

How can the application catch this error message and other errors that get sent in this format to the application’s callback endpoint?

Solution

This will vary significantly depending on the application and frameworks used. However, a basic example using Javascript could look like the following:

const urlParams = new URLSearchParams(window.location.search);
const errorDescription = urlParams.get('error_description');
if (errorDescription === 'user is blocked') {
   // then render a custom message e.g. 'You are blocked. Please contact support'
}