The Laravel framework is an open-sourced PHP web framework that allows developers to create dynamic and scalable web applications. The source code of Laravel is hosted on GitHub and released under the MIT license.
Questions tagged [laravel-sanctum]
585 questions
7
votes
0 answers
Laravel 9 and 10 is using x15 ram than previous version (probably due to SANCTUM), how to opitmize?
I have 3 Laravel applications, one running on Laravel 6 and 2 running on Laravel 8.
They all uses Vue and JWT auth from tymondesigns, and I've plan to upgrade them all to Laravel 10.
But after I successfully rebuilt one of my application to have…

SymmetricsWeb
- 586
- 6
- 20
7
votes
2 answers
How to integrate Spatie's laravel-permission with JetStream properly?
I have a nicely working basic install of Laravel JetStream and Spatie's laravel-permission in Laravel 8.
I can assign a role to the user during registration via
$user->assignRole('visitor');
return $user;
and can restrict the available menu items…

Armand Bozsik
- 171
- 1
- 6
7
votes
1 answer
Laravel sanctum limit no of tokens for each user?
I am using laravel sanctum for API authentication for my mobile app.
How can we limit the maximum number of active tokens per user?
Currently, in the personal_access_tokens sanctum generated table, there is no user_id reference. With the current…

Manas
- 3,060
- 4
- 27
- 55
7
votes
4 answers
api endpoint not doing CSRF token validation on Sanctum - CSRF Token Mismatch
I am currently learning Laravel (which is not going particularly smoothly) and I have got a couple of routes configured to test authentication using sanctum.
I am building an API only laravel service with the plan that a ReactJS project will utilise…

Boardy
- 35,417
- 104
- 256
- 447
7
votes
4 answers
Laravel 7 Vue 2 Sanctum Login Error 419; CSRF Token Mismatch
I am using Laravel with default integration of Vue (Not separate project using Vue CLI). I'm trying to authenticate a user but it always shows 419 error. I have included the csrf token to the Axios's header but it still provides mismatch…

Afiq Rosli
- 357
- 1
- 7
- 22
6
votes
3 answers
Next-Auth Credentials Provider with Laravel - Request failed with status code 419
I have a NextJS Frontend with Next-Auth installed and a Laravel Backend using Sanctum
When I try to login using the signIn function of Next-Auth, it gives me this error:
Request failed with status code 419
419 has to do with CSRF token but I am…

Arjun
- 199
- 2
- 12
6
votes
6 answers
Laravel Sanctum | Delete current user token not working
i really need help with one little thing I try to do. I try to use concurrent personal_access_tokens in my laravel / Vue setup for one user. Everything is working fine, all but one thing where I want to delete one token by it's id when the user is…

Taranis
- 314
- 1
- 2
- 11
6
votes
1 answer
Is Laravel Sanctum suitable to give API access to Third-party server?
We built an API (which currently contains just a single route) to give access to specific data to another company we are working with.
The API calls this other company performs to our endpoint are server-side.
The API has been created with Laravel…

Alice
- 116
- 8
6
votes
6 answers
Laravel 8 Sanctum SPA Auth - Session store not set on request
I'm trying to implement Sanctum SPA Authentication. I'm getting the following error when trying to login (only in production):
production.ERROR: Session store not set on request. {"userId":1,"exception":"[object] (RuntimeException(code: 0): Session…

froston
- 1,027
- 1
- 12
- 24
6
votes
4 answers
Laravel sanctum SPA authentication logout is not working
I am using laravel sanctum SPA authentication in my Vue project.Everything is working well but even after logout
Auth::logout()
I am still able to get datas from api route inside middleware
Route::middleware('auth:sanctum')->get('/user', function…

Pemba Tamang
- 166
- 1
- 3
- 14
6
votes
0 answers
Authentication problem in SSR mode Nuxt on laravel sanctum
Setup is based on Laranuxt - Combination of Laravel 7 and Nuxt. Running on Windows with PHP 7.4.8
Ive been trying to authenticate a user on a nuxt application through Laravel 7 with Sanctum authenticator module. I now get a response that that seems…

Stian Blåsberg
- 115
- 2
- 8
6
votes
0 answers
Test throws RequestGuard::viaRemember() does not exist on second request
I have a test that looks like so:
$user = factory(User::class)->state('verified')->create();
$this->be($user);
$file = new UploadedFile(storage_path('testing/user.jpg'), 'user.jpg', 'image/jpeg');
$this->post('/account/missing-fields/upload', [
…

Jazerix
- 4,729
- 10
- 39
- 71
6
votes
1 answer
CSRF Cookies Not Set for Cross Domain Requests using Laravel Sanctum and Angular
Overview
I have a Laravel powered api locally hosted at http://tenant.api.hydrogen.local and an Angular 9.2 SPA which is being served on http://localhost:8100. I recently installed Laravel Sanctum for authentication and followed instructions for…

cubiclewar
- 1,569
- 3
- 20
- 37
5
votes
3 answers
Fresh Laravel Sanctum API redirecting to '/dashboard' route
I have a fresh installation of Laravel Sanctum API. When I try to log a user in after registration or when submitting the registration form twice, I get an exception with the message "The route dashboard could not be found". I don't understand why…

Hamid Hosseini
- 413
- 1
- 5
- 15
5
votes
2 answers
Laravel sanctum csrf cookie set issue "attempt to set a cookie via a Set-Cookie header was blocked because its Domain attribute..."
I have an issue with the Laravel Sanctum CSRF Cookie's.
I run an API with Laravel 8 on a subdomain: api.domain.nl
And a front end with NuxtJS on domain.nl
Now I want to protect my POST requests that are going to the api.domain.nl with a CSRF cookie…

Finn
- 127
- 1
- 1
- 12