Questions tagged [laravel-sanctum]

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.

585 questions
51
votes
1 answer

Laravel Sanctum vs Passport

What are the differences between these 2? And which one is better for a simple VueJS app? I've read their documents a few times but still confused. Thank you very much.
Daniel
  • 840
  • 1
  • 8
  • 9
24
votes
4 answers

Laravel 7 Sanctum logout

I'm using Laravel 7 with Sanctum authentication for my app. How can i implement the logout procedure? I use: Auth::user()->tokens()->delete(); and it works, but It delete all tokens of this user. i would like to delete only the token of the user…
enfix
  • 6,680
  • 12
  • 55
  • 80
23
votes
9 answers

Getting 401 unauthorized for Laravel sanctum

I am using Laravel Sanctum with Vuejs SPA. Both reside on same top level domain Laravel backend : app.demo.localhost Vue SPA : app-spa.demo.localhost Login and logout (endpoints) are working correctly when called from VueJS SPA using axios and…
21
votes
9 answers

Getting user data with Laravel Sanctum

I was using Laravel's built-in api token authentication before but I wanted to provide multiple api tokens for different clients and with Laravel 7.x, I'm trying to migrate to Laravel Sanctum. API seems authenticates user without any problem but…
she hates me
  • 1,212
  • 5
  • 25
  • 44
17
votes
3 answers

Laravel 8: Using Fortify in APIs

Can Laravel Fortify be used in the context of API? From what I understand, Fortify (although being headless, i.e. doesn't include a UI layer) allows us to customize Login and Register pages, but it automatically redirects to HOME page upon…
dotNET
  • 33,414
  • 24
  • 162
  • 251
16
votes
4 answers

How does Laravel sanctum expire tokens?

When I run $user->currentAccessToken()->delete(); the token expires, Auth::check() becomes false, what it is expected. However, when I go to the personal_access_tokens table, the token is still there. There is no soft delete field. How does Sanctum…
Inigo EC
  • 2,178
  • 3
  • 22
  • 31
15
votes
13 answers

Laravel sanctum unauthenticated

I am using Laravel sanctum in my project with angular as frontend. Getting unauthenticated from the second api request. Please let me know where am I going wrong Frontend-> 127.0.0.1:4200 Backend-> localhost:8888 .env…
user3326941
  • 331
  • 1
  • 4
  • 14
12
votes
8 answers

Laravel Sanctum can be use Multiauth guard

I'm testing with laravel sanctum but here some issues.. I'm creating Admin guard. When I change the middleware to auth:sanctum_admin.. it should be only can access by admin but here I can access with normal user account with web guard. I don't know…
Thomas
  • 121
  • 1
  • 1
  • 3
11
votes
10 answers

Laravel Sanctum : column not found: 1054 Unknown column 'api_token' in 'where clause'

package: Sanctum After generate token when request for get data its throw me error like this Illuminate\Database\QueryException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'api_token' in 'where clause' (SQL: select * from `users`…
Parth kharecha
  • 6,135
  • 4
  • 25
  • 41
9
votes
2 answers

Vue + Laravel sanctum CSRF token mismatch 419 error

I get a "419 (unknown status)" error with the message "CSRF token mismatch." POST http://127.0.0.1:8000/login 419 (unknown status) CSRF token mismatch. Laravel server : http://127.0.0.1:8000 Vue server :…
Ryo ID
  • 93
  • 1
  • 3
9
votes
5 answers

CSRF token mismatch Laravel sanctum and Angular http

I have been trying to implement Laravel sanctum, but I am having this error "CSRF token mismatch" even though I followed everything that is said in the Laravel Sanctum documentation cors.php config file 'paths' => [ 'api/*', 'login', …
Advaith
  • 2,490
  • 3
  • 21
  • 36
8
votes
1 answer

Nuxt 3 Authentication with Laravel 9 and Sanctum

I'm using nuxt 3 for a project and can't find an easy way to do authentication with Laravel and Sanctum. The @nuxtjs/axios module is only compatible for nuxt 2 and the package a developer provided for nuxt 3 (@nuxtjs-alt/auth) doesn't provide much…
Giampy71
  • 137
  • 1
  • 5
8
votes
2 answers

Nuxt project throws CSRF token mismatch 419 error while trying to login users through Laravel Sanctum

Structure of the project: 2 folders namely api and client, where api is used for laravel installation and client refers to the nuxt project. Laravel (v-8.00) setups: This is what I have in .env file for the session…
satancorpse
  • 331
  • 6
  • 17
8
votes
2 answers

Laravel 7.x Sanctum (SPA) with Vuejs always returns 401 Unauthorized

So it's been several hours I couldn't figure out the issue even reading through and trying any possible solution available on the internet. I'm using Laravel 7.x with Vue js and struggling with Sanctum SPA authentication. Login request works fine…
Zee
  • 381
  • 2
  • 11
8
votes
1 answer

Laravel Sanctum : blocked by CORS policy with Nuxt Auth module

I have a Laravel website served by Valet on backend.test and a Nuxt SPA on nuxt.backend.test:3005. When I try to authenticate to Sanctum with Nuxt Auth module, I get the CORS error below: Access to XMLHttpRequest at 'http://backend.test/login' from…
DevonDahon
  • 7,460
  • 6
  • 69
  • 114
1
2 3
38 39