Whenever the backend returns an error message, according to the structure of the project is supposed to return a JSON response containig an "error" key with the value of the error message. Same happens even when authentication token is not provided with a request but when the provided token is invalid the server seems to respond with a weird response. If it can be modified according to the pre-mentioned structure i.e. an "error" key with the value of the error message, the error can be easily caught in the frontend and displayed to the user.
{
"detail": "Given token not valid for any token type",
"code": "token_not_valid",
"messages": [
{
"token_class": "AccessToken",
"token_type": "access",
"message": "Token is invalid or expired"
}
]
}
{
"error": "Given token not valid for any token type"
}