Questions tagged [sanctum]
65 questions
6
votes
4 answers
Creating Token with Sanctum in Laravel 9 with no 'expires_at' column
I installed Laravel 9 and Sanctum, made a migration and tried to create token with 'createToken' method from User class which extends from Authenticatable. It's all from Laravel and Sanctum instalation. I used code…

Sandowl
- 73
- 1
- 4
3
votes
0 answers
how can i generate refresh token using laravel sanctum
we know that the token must expire at some point. How can I replace an expired token with a new one in Laravel sanctum?
I haven't come up with a good idea yet

Najmiddin
- 31
- 3
3
votes
1 answer
Why does Laravel Sanctum append token key to the plainTextToken?
Referring to the following code from Sanctum:
public function createToken(string $name, array $abilities = ['*'])
{
$token = $this->tokens()->create([
'name' => $name,
'token' => hash('sha256', $plainTextToken =…

Abdulwahab Almestekawy
- 574
- 2
- 6
- 17
3
votes
2 answers
Laravel Sanctum with uuid column in User model doesn't save tokenable_id
I'm try to use Laravel 8.x and Laravel sanctum 2.14.2 to authenticate my API and UUIDs as the primary key for my User model.
My custom PersonalAccessToken model
use Illuminate\Database\Eloquent\Factories\HasFactory;
use…

Ryo
- 49
- 1
- 8
2
votes
2 answers
Laravel Jetstream/Sanctum API authentication
I have been working with Laravel since version 5.X up to version 8.X but always use it for backend API (never used blade template), and always pair it with VueJS on the front-end using JWT authentication (also never messed with any other…

SymmetricsWeb
- 586
- 6
- 20
2
votes
0 answers
Laravel Sanctum token validation for specific model
Sanctum makes it possible, when creating a token, to specify the model to which this token belongs - in the table, the tokenable_type field.
For…

KordDEM
- 177
- 10
2
votes
1 answer
Laravel Sanctum and Cookie-Based Session Security
So I have a SPA set up to authenticate with a Laravel application using Laravel Sanctum's suggested cookie-based authentication.
I'm having a bit of a hard time understanding the security surrounding using the cookie-based sessions however. From…

Nick Davies
- 573
- 5
- 15
2
votes
1 answer
laravel Auth::login($user) always return 401 Unauthorized
I'm a newbie in laravel. I work with a simple blog with angular and laravel. I use Sanctum for authorization and registration.
This is my code AuthController:

данил куролесов
- 71
- 1
- 7
1
vote
0 answers
Using Laravel Sanctum, how can I access guarded web routes?
I have Laravel Sanctum set up for API and Web routes.
My guarded Web routes are defined like so:
Route::get('/my-account', [UserController::class, 'getMyAccount'])
->middleware('auth:sanctum');
As for how I'm storing the token, on login and…

UndercoverCoder
- 953
- 3
- 13
- 28
1
vote
0 answers
Laravel Sanctum SPA ReactJS Cors Error on subdomain
I have been trying to solve this issue for the pass 5 days and been searched every where on internet every solution tried in last same error Cors origin
my api is on api.mydomain.edu.af and spa is on spa.mydomain.edu.af
i am shared all necessary…

Hedayatullah Hedayat
- 11
- 3
1
vote
1 answer
How can i localize Laravel Sanctum "unauthenticated" error message?
There is a similar question, where one asked how to change the unauthenticated message (How to change laravel sanctum return "message": "Unauthenticated.").
However, I would like to localize it using my lang/en/auth.php, lang/de/auth.php…

Tamás H
- 11
- 3
1
vote
0 answers
Laravel 9 Sanctum (with cookies) error 401 after successful login SPA React
I am building the authentication of a SPA in React with Laravel 9 Sanctum. I have my SPA at https://agefa.devetapia.cl and the server at https://backend.devetapia.cl. I am authenticating using cookies (not token) and everything is fine until login.…

Eduardo Tapia
- 31
- 1
- 8
1
vote
0 answers
Laravel-Nuxt Sanctum CSRF mismatch when deployed
I have two separate projects frontend nuxt and backend laravel. I used netlify to deploy frontend and Hostinger to deploy backend. I used Nuxt auth and laravel sanctum as authentication. Even if the application runs without any problem in the local…

Nisitha Sankalpana
- 11
- 2
1
vote
0 answers
React and laravel sanctum, blocked by CORS
I'm starting to make an application for myself - on the frontend in React, and the backend in Laravel. I am completely inexperienced in React and am trying to do authentication at this point.
On the backend I am using Laravel Sanctum and Fortify,…

zielonyy3
- 21
- 1
1
vote
3 answers
CSRF Token Mismatch On Axios Post Requests In Laravel
I am working on a project with a React front-end and a Laravel back-end. I am trying to set up my authentication system. I am utilizing SPA authentication using Sanctum. I am successfully utilizing the sanctum/csrf-cookie route, where the XSRF-Token…

Clay Raymond
- 13
- 1
- 5