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
0
votes
1 answer
laravel jetstream request api route middleware protected api:sanctum return unauthenticated response
I have a problem with 'domain' => env ('SESSION_DOMAIN', null) in the session.php file. When set SESSION_DOMAIN value in .env file, for example
SESSION_DOMAIN=mysite.test
login don't works and there seems to be a middlaware.
If not set this…

lorenzo taccogna
- 1
- 1
0
votes
1 answer
App like Kahoot; Laravel Sanctum or Passport?
I want to build a game-app like kahoot, for fun! :)
This will be an app where guests can either register and create a game or just get invited and enter the created game with a PIN. Then they can answer all kinds of questions.
It will be a SPA…

Springsteen91
- 25
- 4
0
votes
0 answers
Laravel Sanctum returns 401
I try to access my Laraval API from my Vue SPA but everytime I do a request I get a 401 Unauthorized. I have tried the answers from multiple SO questions but nothing works.
I added the EnsureFrontendRequestsAreStateful to the API middleware.
I set…

Bart Bergmans
- 4,061
- 3
- 28
- 56
0
votes
1 answer
Sanctum can't find personal_access_tokens table when using stancl multi-tenancy
As i can see, everything is fine - the table exists and there is correct token for the user that is making a request when using stancl multi-tenancy. Also, when i make a request to the database from console, the response is correct, for example -…

Dickilla
- 11
- 1
- 2
0
votes
1 answer
Sanctum authentication with roles
I'm trying to implement Sanctum SPA authentication with roles (user/admin). The thing is that I want to use separate admin table.
Read all of the laravel documentation related to that subject but with no result.
Tried to make a new guard and…

teranshil
- 109
- 1
- 6
0
votes
1 answer
Using Laravel sanctum for Laravel default authentication returns 419 error code
I am using Laravel Sanctum for making authentication. I don't have any SPA application and I want to have Laravel Sanctum for having default authentication.
I have followed the documentation but I've got 419 error code.

ali Falahati
- 599
- 7
- 18
0
votes
2 answers
Authentication in Laravel API with sanctum
I've been hitting my login endpoint using POSTMAN and on the browser but i'm always met with the 'unauthorized' error. I have added the required configurations for Sanctum and Cors in the config folder.
Here is my code
public function login(Request…

LDUBBS
- 593
- 2
- 8
- 20
0
votes
1 answer
Laravel "Unauthenticated" error in specific route
In my Laravel 7 backend I have some api url like:
Route::group(['namespace' => 'Api', 'middleware' => ['auth:sanctum']], function(){
Route::post('logout/all', 'Auth\LoginController@logoutAll');
Route::post('logout',…

enfix
- 6,680
- 12
- 55
- 80
0
votes
1 answer
Laravel returns unauthorized with second request
I'm trying to create SPA. I use Laravel API for backend and Nuxt.js for frontend. I want to authenticate users via Laravel Sanctum. I run backend on localhost:8000 and frontend on localhost:3000. SANCTUM_STATEFUL_DOMAINS is set to localhost:3000,…

tapseoff
- 81
- 1
- 5
0
votes
2 answers
Laravel sanctum on product/staging server returning 401 after successful login
I am working on a web application at the moment that has a an api at the top level domain (mydomain.com) and an SPA at subdomain (spa.mydomain.com). In the SPA I have added,
axios.defaults.withCredentials = true
To login in I run the following code,…

Udders
- 6,914
- 24
- 102
- 194
0
votes
0 answers
How to get details for laravel sanctum
I know that with JWT, you can decode the token and get the details from it. In doing so you can validate in your standalone frontend app.(eg Vue js)
Is there a way to do the same thing with laravel sanctum with an SPA not on the same domain? If yes…

Precious Aang
- 53
- 1
- 4
- 12
0
votes
0 answers
Laravel Sanctum For making Api
I am testing Laravel Api and using Sanctum for token and i followed the documentation for sanctum but when i used the Route as
Route::middleware('auth:sanctum')->get('user', function () {
return User::all();
});
I am getting the message as…

shub-naik
- 21
- 1
- 2
0
votes
1 answer
How to keep Laravel Auth routes with vuejs routing?
As I've seen in many tutorials, I used the following code to be able to use the vue-router:
Route::get('/', function () {
return view('welcome');
});
Auth::routes();
Route::get('/{any}', function () {
return view('home');
})->where('any',…

Inigo EC
- 2,178
- 3
- 22
- 31
0
votes
1 answer
Laravel sanctum scope for nuxtjs frontend
So i'm trying to establish some kind of policy inbetween the frontend and backend, all works fine however i'm a little confused towards declaring a scope for my application users
ApiSessionController.php
public function login(Request $request)
{
…

RWE
- 15
- 8
0
votes
0 answers
Laravel Sancrum/Airlock
I'm trying to host a Laravel API (Sever) project on Heruko along with Vue js project separately, 2 individual project. Is it possible to use laravel airlock/sanctum to authenticate user on the heruko free given domain?

Parchie
- 26
- 1