Laravel Sanctum

Laravel Sanctum provides API authentication through personal tokens, as well as session cookie authentication for single-page applications. The token is sent in the Authorization: Bearer header, and the route is protected by the auth:sanctum middleware. Tokens can carry abilities.

Example

Route::middleware('auth:sanctum')->get('/me', fn (Request $r) => $r->user());

Related concepts

The whole glossary