Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
Demonstrates a simple Laravel API protected using Passport with routes for retrieving user data.
// routes/api.php
use IlluminateSupportFacadesRoute;
Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});
// App/Models/User.php
use LaravelPassportHasApiTokens;
class User extends Authenticatable {
use HasApiTokens, Notifiable;
}
// AuthServiceProvider.php
use LaravelPassportPassport;
public function boot() {
$this->registerPolicies();
Passport::routes();
}Laravel Passport is an OAuth2 server implementation for API authentication in Laravel applications, providing a full OAuth2 server setup with minimal configuration.
Origin & Creator
Created and maintained by Taylor Otwell as part of the Laravel ecosystem.
Industrial Note
Laravel Passport is used in enterprise APIs, SaaS applications, mobile backends, and SPAs where secure token-based authentication and OAuth2 compliance are required.