Use Laravel Sanctum To Make Laravel Api Authentication For Users - FreeCodeBlog

Last updated: Nov 09, 2021

In this tutorial I will use laravel sanctum package to make laravel api authentication for users. For spa authentication or laravel vue api authentication you need to use laravel fast party package (laravel sanctum).

 

Use Laravel Sanctum To Make Laravel Api Authentication For Users
Use Laravel Sanctum To Make Laravel Api Authentication For Users

 

Warning.

Skip this tutorial If you have a laravel website that used laravel jet-stream package because laravel jetstream included laravel sanctum by default.

 

Laravel To Make Sanctum Api Authentication. 

Please install laravel 8 to use laravel sanctum to make laravel API authentication. I already installed laravel 8. If you don't know how to install laravel then read how to install any kind of laravel version tutorial.

 

Laravel Sanctum To Make Api Authentication.

Now you need to install laravel sanctum first party package.

 

composer require laravel/sanctum

 

Next, you should publish the Sanctum configuration and migration files using the below artisan command. The sanctum configuration file will be placed in your application's config directory.

 

php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider"

 

Laravel Ui To Make Sanctum Api Authentication.

If you haven't installed laravel ui 3 or don't know how to install laravel ui 3 then read install laravel ui package in any kind of laravel version tutorial. For this tutorial I already installed laravel ui 3 to use laravel sanctum for API authentication. 

 

Compile CSS & Js Files To Make Sanctum Api Authentication.

If you don't know much about css and js files complication then read how to compile laravel css and js files tutorial. Don't forget to compile css and js files after use laravel sanctum to make API authentication. 

 

Database Connection To Make Sanctum Api Authentication.

I already connect MySQL database with my use laravel sanctum API project. read how to connect database connection in laravel tutorial if you don't know about laravel database connection.

 

Thanks.

Post Tags
Post Writer
masum7323
Masum Biswas (@masum7323)

My name is Masum Biswas. I'm a full stack developer. I live in Bangladesh and I love to write tutorials and tools that can help to other artisan. I am a big fan of PHP, Javascript, JQuery, Laravel, MySQL, VueJS, Tailwind CSS and Bootstrap from the early stage.

Follow Me On
Related Posts
Laravel 8 User Phone Number Verification Using Nexmo And Breeze

Send a code sms to user phone number  for number verification when user will register with phone number in laravel 8. In this tutorial I will... Read More

Use Moment Js In Laravel 8 With Vue 3 And Breeze Inertia

Laravel 8 breeze moment js with vue 3! Want to use moment js in laravel 8 vue 3 with laravel breeze inertia js? Yes! Okay sometimes you may need to... Read More

Laravel Ui Email Verification Complete Tutorial

Want to make laravel ui vue, react, bootstrap email verification using laravel ui version 3, 2, 1? Laravel ui has a feature for users to verify ema... Read More

Make Laravel User Authentication Using Laravel Ui In Laravel 8 With Vue 2

Install and use laravel ui package in laravel 8 with Vue 2 to make user authentication. Laravel UI is a new first-party package that extracts the U... Read More

How To Deploy A Laravel 8 Project On Namecheap Shared Hosting Cpanel

Today I will explain you, how we can easily deploy a laravel 8 project on namecheap shared hosting cpanel. If you have a namecheap shared hosting s... Read More