Laravel sanctum and Vue-JS SPA

Aus Froggis Wissenssammlung
Version vom 13. August 2020, 13:35 Uhr von Froggi (Diskussion | Beiträge) (→‎2. Use it to authenticate a user)
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Wechseln zu:Navigation, Suche

1. Install laravel sanctum

You may install Laravel Sanctum via Composer:

composer require laravel/sanctum

Now follow the instructions from https://laravel.com/docs/7.x/sanctum#installation to complete the installation. Especially look at the configuration.

2. Use it to authenticate a user

As described in the official docs do:


 axios.get('/sanctum/csrf-cookie').then(response => {
 // Login...
 });

The login can be the standard login of Laravels scaffolding or a custom one.