Source: alexandru-dumitru.medium.com

Laravel API Auth with Sanctum

Category: Laravel, PHP, MySQL, api

But you already know that since you are here. In the following lines we will build an authentication system using sanctum.

I also recommend to set a header Accept: application/json in the Headers section in order to receive the errors descriptions more readable.

Now the route for this should be accessible only if the user is logged in. In order to achieve this, we define our route inside a group with the auth:sanctum middleware.

In the future posts we will build a simple Angular app that will consume this api.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners