Category : laravel-sanctum

I am trying to implement a simple project using Laravel API as backend and VueJs as frontend. I use Laravel Sanctum for authentication. Everything works fine, however, after i redirect to external url (payment gateway) my user session gets destroyed and user have to login again after the response from the external url. My settings ..

Read more

I am using VueJS and Laravel API SPA with Sanctum. While submitting my login details on localhost:8000/login i face no issue, however, while trying to run the same using 127.0.0.1:8000/login i get a message "CSRF token mismatch." my settings are as under .env file SESSION_DRIVER=cookie SANCTUM_STATEFUL_DOMAINS=127.0.0.1:8000,localhost:8000,localhost:3000,127.0.0.1:3000 SESSION_DOMAIN=localhost,127.0.0.1 cors: ‘paths’ => [‘api/*’, ‘sanctum/csrf-cookie’], ‘allowed_methods’ => [‘*’], ..

Read more

I have problem with laravel sanctum usage in Angular SPA application. Acutal documentation for laravel 8.x says: If the login request is successful, you will be authenticated and subsequent requests to your application’s routes will automatically be authenticated via the session cookie that the Laravel application issued to your client. In addition, since your application ..

Read more

SPA : localhost:8080 vue 3/ vuex 4/ axios / typscript Laravel : domain.test //api for api access, /nova for nova access, web routes for public access laravel 8 / sanctum / nova / fortify error on posting to /login: config/fortify.php <?php use AppProvidersRouteServiceProvider; use LaravelFortifyFeatures; return [ ‘guard’ => ‘web’, ‘passwords’ => ‘users’, ‘username’ => ..

Read more

After migrating from Laravel 5.6 to Laravel 7, middleware that has a ":" in It does not work. For example "auth:basic" or "auth:sanctum": Route::middleware([‘auth:basic’])->group(function () { }); If I use It as auth.basic, It works perfectly, but not auth:basic. The exeption is: message: "Function name must be a string", exception: "Error", file: "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", I would ..

Read more

I have the following set-up: Laravel running with Homestead Domain laravel-api.test pointing to my Homestead environment React (npx create-react-app) running locally with a custom HOST app.laravel-api.test:3000 Laravel In my routes (routes/api.php) I added two routes: Route::post(‘login’, [AppHttpControllersLoginController::class, ‘login’]); Route::middleware(‘auth:sanctum’)->get(‘books’, [AppHttpControllersBookController::class, ‘list’]); In my config/cors.php I added: ‘paths’ => [‘api/*’, ‘sanctum/csrf-cookie’], ‘allowed_methods’ => [‘*’], ‘allowed_origins’ => ..

Read more

I want to generate a jwt token using sanctum without user login! $user = DB::table(‘social_facebook_accounts’) ->select(‘id’ ,’provider_user_id’,’provider’) ->get() ->sortByDesc(‘updated_at’) ->first(); if($user->provider_user_id == $userid){ $success[‘token’] = $user->createToken(‘facebook’)->accessToken; return response()->json([‘success’ => $success], $this->successStatus); }else{ return response()->json([‘error’=>’Unauthorised’], 401); } error I am getting => Call to undefined method stdClass::createToken() Sourc..

Read more