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
4
votes
4 answers
How do I fix the "401 Unauthorized" error with Laravel 8 Sanctum and VueJS 3?
So I have this Laravel 8 project with VueJS 3 in the frontend, and I'm running it on my localhost
And I'm using Sanctum for my authentication.
The Login and Sign Up process works fine, but when I go to a dashboard and I try to add something to my…

Hamza Radouan
- 152
- 2
- 12
4
votes
1 answer
Using Laravel 8 with Sanctum hasapitokens to login with a remember me option
So Im building a SPA with Vue 3, Laravel 8 and using sanctum (hasapitokens) to handle the user login and I could not find the duration of the session that the token is valid as I wanted to use this in combination with a remember me option when a…

user759235
- 2,147
- 3
- 39
- 77
4
votes
4 answers
How to get user by Token in Sanctum Laravel
I'm passing to the server in the POST request body the Token of the user. I need to find out which user this token belongs to. In laravel/sanctum documentation I found out that it is possible to do it only by putting the Token as "Authorization":…

Dmytro Huz
- 1,514
- 2
- 14
- 22
4
votes
4 answers
Laravel Sanctum unauthenticated using postman
I follow the Laravel official document step by step.
When I send a request to {{host}}/api/login, I can receive the response that includes the token. Everything is correct.
But when I try to send a request to {{host}}/api/user, it is always…

Ramsey Jiang
- 81
- 1
- 7
4
votes
0 answers
Cookie problem for Laravel Sanctum on local dev environment
I am working locally on a project where my Laravel backend is running by Laravel Valet on the url https://backend.app and my frontend is a Vue project running on http://localhost:8080.
When I do the call from my frontend to my backend to generate…

Bart Bergmans
- 4,061
- 3
- 28
- 56
4
votes
1 answer
SPA authentication using sanctum failed with this error message: "Unauthenticated."
I am building SPA with Vuejs and Laravel, I installed the laravel sanctum to authenticate the user by its token.
Api.php
Route::post('/teacher/login', 'Teacher\RegisterController@login')->middleware('auth:sanctum');
Login.Vue
login(){
…

Hadayat Niazi
- 1,991
- 3
- 16
- 28
4
votes
0 answers
Laravel Sanctum & Laravel Echo in NuxtJS - Private Channel and Presence Channel not working
I can't handle authorization (or something else) on private and presence channels. Regular channels work fine.
I am using latest Larvel and NuxtJS with Auth-next (v5).
I am using Laravel Sanctum in SPA mode.
// nuxt.config.js
echo: {
…
user14166158
4
votes
2 answers
Laravel Sanctum: How to configure the expiration date of the token?
Context and Need
In my api routes file, I've written the following code following the documentation (https://laravel.com/docs/8.x/sanctum#introduction) :
Route::post('/tokens/create', function (Request $request) {
$token =…

JarsOfJam-Scheduler
- 2,809
- 3
- 31
- 70
4
votes
0 answers
Both token and refresh token have expired. Your request was aborted
Im trying to login from my nuxt app to my laravel sanctum back end but when I try to submit my form it throws an error
Login.vue