675 questions
0
votes
1
answer
581
views
How to access XSRF-TOKEN value from Laravel when using Sanctum
I created a custom Slack app that is enabled from within my Vue/Laravel app, and, per the Slack docs when enabling the app and authenticating via OAuth, you pass in a value as the state value, and ...
3
votes
0
answers
239
views
Laravel Sanctum returns randomly 401 after succesfully authenticating
I am developing a dashboard using Laravel and VueJS, with both on different servers. I have no problems with my local development environment on my PC and the production server. However, on the ...
2
votes
1
answer
54
views
Laravel's $request->user()->id; is giving me first logged in user not current one
Am developing in laravel 10, i use sanctum token authentications
but on my controller methods only returns first logged in user not current one
public function getUser( Request $request ) {
return $...
0
votes
0
answers
28
views
How to prevent Laravel from sharing session/cookies between multiple subdomains [duplicate]
I am using Laravel with Sanctum.
I have 2 SPA's (Vue apps) at different ports:
localhost:8080 -> spa1 (admin area)
localhost:8081 -> spa2 (member area)
My API communicates with both SPAs.
...
0
votes
1
answer
1k
views
Sanctum Guard Error With using Spatie Package in laravel
I receive a Sanctum guard error when I try to find a specific Role_id or Permission_id using a Spatie package in Laravel. It was working fine normally when I try to get all roles or permissions but it ...
0
votes
0
answers
168
views
Error "GET http://myapi.host.com/api/user net::ERR_EMPTY_RESPONSE" when using header 'Authorization'
Im usgin Laravel Sanctum auth for my API. When i try to make a call to an endpoint that is handled by 'auth:sanctum' middleware, i cannot put the 'Authorization' header cause if i use it, i get the ...
0
votes
2
answers
852
views
Laravel on sub domain ignore parent cookies when
I have a laravel app on a parent domain. SESSION_DOMAIN is set to .domain.com because I want the cookies to be shared with another subdomain first.domain.com.
I now want to publish another app at ...
0
votes
0
answers
898
views
Laravel Pusher/Echo/Soketi AccessDeniedHttpException
So, I'm attempting to use laravel jetstream inertia with vue with no ssr. When trying to use broadcast private channels with laravel-echo I keep getting AccessDeniedHttpException exception with no ...
1
vote
0
answers
517
views
Santum 419 CORS issue
I've found a lot of question about this issue but none of those answers work for me.
I'm trying to authenticate a user from my vuejs SPA to laravel 10.9 sanctum API.
It seems like the axios.get('/...
0
votes
1
answer
298
views
getting error during user logout in laravel using postman
Trying to logout a logged in user using postman in laravel sanctum.
But error appearing like below:
Argument 1 passed to Illuminate\\Routing\\RouteFileRegistrar::{closure}() must be an instance of ...
0
votes
1
answer
276
views
Error eager loading roles with users laravel permissions
When attempting to eager load roles with their assigned users from Spatie's laravel-permissions library like this
use Spatie\Permission\Models\Role;
Role::with('users')->get();
This error occurs
...
0
votes
0
answers
290
views
How can I implement API authentication using regular credentials (e.g. cookies) in Laravel with Sanctum?
My app normally uses the web routes with their regular cookie-based authentication, but in some places I need to use AJAX just for convenience (e. g. sending a message without reloading the page). ...
0
votes
1
answer
3k
views
Laravel Sanctum for API auth on different domain
I was authenticating API requests in Laravel and It was working on local perfectly but When I deployed both (React on Firebase, Laravel on different domain), API authentication stopped working.
This ...
1
vote
1
answer
751
views
csrf token is getting expired before getting consumed
Why does my csrf token expires as soon as I try to use it?
I'm having a weird problem with the XSRF token and session token I receive and send back with Angular.
When I make a request to the endpoint ...
0
votes
1
answer
115
views
Not getting auth token on mobile app but getting it from Postman
I'm trying to authenticate a Flutter app built on Flutter Flow. I've created a post request to authenticate the user from the app. I can confirm that the token gets generated whenever the user logs in ...
0
votes
0
answers
96
views
Laravel Sanctum - user two laravel for microservice (401 "Unauthenticated.")(Solved)
I Have two project of laravel and one of them have sanctum.and I wrote a middleware for another laravel project.
My middlware:
$url = 'http://localhost/v1/management/auth/me';
$suepackAuth = ...
0
votes
1
answer
891
views
401 (Unauthorized) Laravel API VueJS
im using laravel 9 and vue js 3 composition API, i always get error 401 when i want to get login user data/ authenticated user, i have tried to find a way and use all the ways, from config settings, ...
-1
votes
1
answer
1k
views
How to validate if the Sanctum token i valid or not in laravel 9
I want to create an api to check if the token is expired or wrong on laravel 9 but when the token is wrong the postman gave me a response with html page and ignoring my middleware that validates the ...
1
vote
2
answers
2k
views
Laravel Sanctum always returns 401 unauthorized in Production
I am using this starter vitesse-nuxt3 with backend Laravel 9 Sanctum setup. I also use nuxt-sanctum-auth package and it is totally working fine in my local development.
However, in production, I'm ...
1
vote
0
answers
185
views
Laravel 9 API with sanctum authentication in production api route not working
I have created APIs with sanctum authentication and moved the laravel application into the production server after uploading it to the server, the production API route are not working
I have check my ...
1
vote
1
answer
1k
views
Sanctum unauthenticated response when Bearer token is set
When I try to enter an end-point, the Sanctum middleware throws an "Unauthenticated"(401) response. Whenever a user logs in, I encrypt the token and attach it as a cookie to the client side; ...
3
votes
2
answers
7k
views
Cannot set CSRF cookie using Laravel Sanctum on the frontend
I was recently trying to implement the Laravel Sanctum authentication with Nuxt 3, but have come across a problem with the initial CSRF cookie handshake. The thing is that after I make a request to ...
0
votes
1
answer
682
views
Laravel Auth guard not working on some shared hostings
I made a project with laravel multiple auth guard with sanctum it perfectly work on localhost but after upload to shared hosting it not authenticate the user. login process work fine and return token ...
0
votes
1
answer
175
views
Laravel & vue project structure and organisation
I am wanting to build a proof of concept, and I want some enlightment on the project structure, it will be a Laravel 10 project on the server, with a vue3 front-end. I am wanting to house it all ...
1
vote
1
answer
2k
views
CSRF token mismatch error due to Laravel Sanctum not being able to set CSRF cookie in front end app
I have deployed two apps using https://fly.io/;
Laravel (v9) API backend
VueJS front end
Both apps are loading fine in the web browser.
The front end uses Laravel’s Sanctum library for ...
0
votes
2
answers
2k
views
Laravel 8 – Sanctum Personal Access Token – Web Route Secure With Redirect
One part of the goal here is to deepen my knowledge about the framework, so even if this isn’t “the right way”, I’d still like to try a solution to check if I should proceed with sanctum or passport.
...
1
vote
2
answers
54
views
How to retrieve limited records if the user is not logged in and all records if the user is logged in in Laravel?
I have a Laravel route that I want to handle differently depending on whether the user is logged in or not. If the user is not logged in, I want to retrieve only 5 records (limit 5) in the controller. ...
1
vote
1
answer
2k
views
Laravel 8 Sanctum Authentication Token With Custom Model Returning Integrity constraint violation: 1048 Column 'tokenable_id' cannot be null error
I have low experience with token authentication and sanctum.
General Context:
I’m currently migrating a framework of mine to Laravel and still in the early stages. I know that Laravel has its own ...
0
votes
2
answers
955
views
Traying to attempt credential of non-default guard in Laravel using if(!Auth::guard('mobile')->attempt($credentials))
in my project I have two guards, the first is "web" related to admins table with session driver, and the second one is "mobile" related to users table with token driver.
'defaults' ...
8
votes
1
answer
1k
views
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 ...
0
votes
1
answer
1k
views
Laravel using rest api source for both mobile and browser with authorization
I have an rest api that, depending on whether the user is authorized or not, issues different products /api/products. This api for a mobile application, I carry out authorization through a bearer ...
1
vote
1
answer
2k
views
Laravel sanctum how to check token for all api requests?
I have an rest api /api/example
need to provide different json information for authorized and unauthorized users.
If I use the standard middleware('auth:sanctum') then the user who has the token will ...
1
vote
2
answers
2k
views
Auth:sanctum middleware not protecting routes
I installed Sanctum on my Laravel 9 site (one that I've been updating over the years over several versions), in order to try out adding token generation to my API. I got the token generation working,...
2
votes
1
answer
1k
views
Nuxt 3 useFetch POST request send a 419 unknown status error
I develop a web app with NuxtJS and Laravel.
When I send a POST request with useFetch, I have a 419 error, and no more information (it is an unknown status).
I launch sanctum/csrf-cookie request, and ...
1
vote
1
answer
474
views
Laravel custom middleware for 2 databases
I don’t know how to create middleware for two databases tokens.
(First of all my english is not very well and I am beginner in laravel) I created a Laravel project that has two Eloquent ...
0
votes
1
answer
505
views
Logging out from SPA using Laravel api
I have two applications: SPA built with Vuejs 3 and the API built with Laravel.
the SPA is running on 127.0.0.1:5173 and the api is running on 127.0.0.1:8000
The user can authenticate successfully but ...
0
votes
2
answers
2k
views
Laravel Authentication API Sanctum – With Custom Database
First important information: I’m new to Laravel, so your patience is appreciated.
I’m currently migrating a framework of mine to Laravel and still in the early stages. I know that Laravel has it’s own ...
1
vote
1
answer
1k
views
Composable for checking Laravel Sanctum's CSRF token in Nuxt 3
I'm working on a Nuxt 3 app with Laravel 9 as API with Sanctum and Fortify.
I wrote a composable to check the response to the Laravel Sanctum's CSRF token HTTP route ('/sanctum/csrf-cookie') and I'm ...
2
votes
1
answer
3k
views
Laravel : How can I modify auth:sanctum middleware to return a 401 instead of redirect to login route?
Good evening,
I encounter a problem using Laravel and Sanctum to build an Api for a Mobile application.
I followed the documentation and define a route to get a token :
use App\Models\User;
use ...
1
vote
1
answer
1k
views
Laravel Sanctum authenticate middleware auth:sanctum for different model
I'm using Laravel Sanctum 3.x in my Laravel 9 project. I'm building a Microservice feature and need to authenticate them via my Microservice model where I've added HasApiTokens and created my tokens.
...
1
vote
1
answer
451
views
Laravel Error: Call to a member function isPast() on string laravel/sanctum/src/Guard.php on line 160
I'm just configured laravel project with sanctum.
And trying to check is ok, making request to /api/user:
Route::post('/login', [AuthController::class, 'login']);
Route::middleware('auth:sanctum')-&...
0
votes
1
answer
611
views
Failure to create Laravel Sanctum token after user has been registered using a One Time Pin (OTP) [duplicate]
I am trying to create a login token for a user after they register on my application and have verified their mobile device using an OTP sent via sms. The problem is that, when a user logs in, the ...
0
votes
1
answer
836
views
Argument 2 passed to Illuminate\\Auth\\SessionGuard::__construct() must implement interface Illuminate\\Contracts\\Auth\\UserProvider [duplicate]
This is my auth.php file
return [
'defaults' => [
'guard' => 'salon_emp',
// 'passwords' => 'users',
],
'guards' => [
'web' => [
'driver'...
0
votes
1
answer
713
views
Laravel Sanctum Angular Authentication 419 error code
I'm trying to setup an authentication system using Laravel Sanctum and Fortify for the back-end and Angular for the front-end.
The front-end is running on localhost:4200
the back-end is running on: ...
0
votes
0
answers
1k
views
How to use Laravel Sanctum without web session?
I want use my app only via api requests (token authorization)
Problem:
I have swagger to test queries. If I send one request with valid token, I can send any another requests without token and I didn'...
0
votes
1
answer
2k
views
Unauthenticated Message In Sanctum
I have read through just about every Stack thread about this but am still getting nowhere. Using fresh install of Laravel 9.48.0.
cors.php:
'paths' => ['api/*', 'sanctum/csrf-cookie'],
'...
1
vote
1
answer
369
views
Using Laravel Sanctum Returns FATAL:SASL Authentication Error
I'm trying to figure out why Sanctum gives off this error when I try to login my system.
SQLSTATE[08006] [7] connection to server at "10.1.80.217", port 5000 failed: FATAL: SASL ...
6
votes
1
answer
2k
views
Use laravel sanctum session-bases with next.js in sever side (like getServerSideProps metod)
I have laravel as backend and next.js as frontend of my website.
I use laravel sanctum for authentication.
My laravel app and next.js app are in the same host, then I can use session-base sanctum for ...
3
votes
1
answer
447
views
401 (Unauthorised) response from Pusher due to failed authentication with Sanctum
Getting a 401 (Unauthorised) response from Pusher due to failed authentication using Laravel Sanctum.
[Error] Pusher : : ["Error: Unable to retrieve auth string from channel-authorization ...
0
votes
0
answers
379
views
CORS redirect issue on a local development environment Laravel and Vue project
I'm having some CORS issues. In my environment I have:
Laravel project running on 127.0.0.1:8000
Vue project running on localhost:8080
This is the configuration of Vue:
const { defineConfig } = ...