#17 Laravel API Tutorial | Laravel Passport Tutorial (I) | Laravel API Authentication with Passport

preview_player
Показать описание
In Part-17 of Laravel 8 API Tutorial and Laravel Passport Tutorial, we will start working on Laravel Passport that is standard to create the Authentication system in Laravel.

Since APIs do not use sessions, we generally use tokens. Laravel uses the Passport library to implement a full OAuth2 server we can use for authentication in our APIs.

We will install Laravel Passport Package in Laravel 8 and work on Register API. We will use Passport API Authentication to generate the Authorization Token and register the user with Auth.

We are going to use Passport in almost every API after login that requires Authorization Token that is securely generated with Passport Library.

1) Install Laravel Passport Package :-
First of all, install Laravel Passport package that will provide full OAuth2 server implementation for our Laravel application.

We will run below composer command to install :-
composer require laravel/passport

In case time out error comes then run below command to install :-
COMPOSER_MEMORY_LIMIT=-1 composer require laravel/passport

2) Run Migration :-
Now run below migration command that will create the tables to store clients and access tokens :-
php artisan migrate

3) Generate keys :-
Now run below command to create the encryption keys needed to generate secure access tokens.
php artisan passport:install

4) Update User Model :-
Now update User model to add HasApiTokens class as shown in video

7) Create Route
// Register API - Register User with API Token

8) Create registerUserWithPostman function :-
Now we will create registerUserWithPostman function in which we will generate Authorization token with Postman.

#laravelapitutorial #laravel8api #laravelapitypes #laravelapiexamples #laravelapi

Learn to make e-commerce website in Laravel 6 / 7 / 8 :-
Рекомендации по теме
Комментарии
Автор

Really Great and I'd like to Thank you all members of Stack Developers, go forward, you are doing the best. Thank you :)

samehyousufi
Автор

Great work done, have been following your tutorial keenly and so educative and informative. Please help me here I stumbled on this error:
{
"message": "Call to undefined method Laravel\\Passport\\Passport::routes()",
"exception": "Error",
"file": "C:\\xampp\\htdocs\\ApiLearning\\app\\Providers\\AuthServiceProvider.php",
"line": 30,
"trace": [
{
"file": "C:\\xampp\\htdocs\\ApiLearning\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\BoundMethod.php",
"line": 36,
"function": "boot",
"class": "App\\Providers\\AuthServiceProvider",
"type": "->"
},

Scholar_region