Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 3630

Customize laravel sanctum unauthorize response

$
0
0

I am using laravel sanctum in my project, but I am facing a problem. I want to customize the 401 response code (unauthorized) to return a JSON when a token is invalid, something like this:

    {"data": {"code": 401,"book": null,"success": false,"error": {"message": "Not authenticated"        }    }}

Instead of default response:

{"message": "Unauthenticated."}

How to achieve this in laravel sanctum? Thanks in advance.


Viewing all articles
Browse latest Browse all 3630

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>