laravel passport api authentication

2019-07-26 23:58发布

I'm new to api authentication (passport) in laravel. Is it possible to guard api routes using

$this->middleware('auth:api');

even if used the laravel built in authentication (php artisan make:auth)?

1条回答
Bombasti
2楼-- · 2019-07-27 00:20

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',
        ],
    ],
查看更多
登录 后发表回答