Laravel Passport | laravel api token
IntroductionLaravelalreadymakesiteasytoperformauthenticationviatraditionalloginforms,butwhataboutAPIs?APIstypicallyusetokenstoauthenticateusersanddonotmaintainsessionstatebetweenrequests.LaravelmakesAPIauthenticationabreezeusingLaravelPassport,whichprovidesafullOAuth2serverimplementationforyourLaravelapplicationinamatterofminutes.PassportisbuiltontopoftheLeagueOAuth2server[1]thatismaintainedbyAndyMillingtonandSimonHamp.{note}ThisdocumentationassumesyouarealreadyfamiliarwithOAuth2.Ifyoudonotk...
IntroductionLaravel already makes it easy to perform authentication via traditional login forms, but what about APIs? APIs typically use tokens to authenticate users and do not maintain session state between requests. Laravel makes API authentication a breeze using Laravel Passport, which provides a full OAuth2 server implementation for your Laravel application in a matter of minutes. Passport is built on top of the League OAuth2 server[1] that is maintained by Andy Millington and Simon Hamp.
{note} This documentation assumes you are already familiar with OAuth2. If you do not know anything about OAuth2, consider familiarizing yourself with the general terminology[2] and features of OAuth2 before continuing.
InstallationTo get started, install Passport via the Composer package manager:
composer require laravel/passport
The Passport service provider registers its own database migration directory with the framework, so you should migrate your da...