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

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners