laravel passport api authentication

与世无争的帅哥 提交于 2019-12-24 07:57:41

问题


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:


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',
        ],
    ],


来源:https://stackoverflow.com/questions/52511906/laravel-passport-api-authentication

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!