Create REST API in Laravel with authentication using Passport
Urjit Rajgor
1.3K26

For the people who still have some issues with the response of : “unauthorized” .

First of all check if you have api_token column in your users table .

If you don’t have , try to alter the table users

Edit the login function (so we can save the generated api_token) :

when you perform you POST request : api/login , copy your token and open new tab on postman , and change the route /api/details .

Don’t forget to change your header by adding :

Authorization : Bearer . {token}

Content-Type : application/json

That’s it :D

PS : Thanks for the article , it’s useful at some points

Like what you read? Give Bour Mohamed Abdelhadi a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.