laravel护照api身份验证
问题描述:
我是Laravel中的api authentication
(护照)的新手.
是否可以使用
I'm new to api authentication
(passport) in laravel.
Is it possible to guard api routes using
$this->middleware('auth:api');
即使使用了内置的laravel身份验证
(php artisan make:auth)
?
even if used the laravel built in authentication
(php artisan make:auth)
?
答
您可以使用auth:api
保护您的api,只需将config/auth.php
you can guard your api with auth:api
, just need to change the api guard driver to passport in config/auth.php
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
//'driver' => 'token',
'driver' => 'passport',
'provider' => 'users',
],
],