Laravel Passport is an OAuth2 server and API authentication package that is simple and enjoyable to use. If your application absolutely needs to support OAuth2, then you should use Laravel Passport. Laravel Passport provides a full 0Auth2 server implementation. With it, you can easily generate a personal access token to uniquely identify a currently authenticated user. For installing this package Run this command from the Terminal: composer require laravel/passport Once the installation is complete, passport migrations will create the tables your application needs to store clients and access tokens.Run the following command to migrate your database: This command will create the encryption keys needed to generate secure access tokens. php artisan passport:install After the installation process, add the LaravelPassportHasApiTokens trait to your AppUser model : Now, to register the routes necessary to issue and revoke access tokens, call the Passport::routes method within the boot method of your AuthServiceProvider. Laravel provides routes/api.php file for writing web services routes. So, add a new route on that file. https://www.letsnurture.com/blog/create-api-rest-with-laravel-passport-authentication.html Create function in your controller file
- Login function
- Logout function