API 接口登录认证会自动到 Web 的登录认证,怎么能将 API 的登录认证不走 Web 的守护
API接口登录认证会自动到web的登录认证,怎么能将API的登录认证不走web的守护?
如果我将config/auth.php中的Authentication Defaults 的配置改成:
'defaults' => [
'guard' => 'api',
'passwords' => 'users',
],
正阳修改后请求接口登录授权认证一切正常,如果将默认的guard 修改为 web 就不行了,错误异常日志:
local.ERROR: Argument 2 passed to Illuminate\Auth\SessionGuard::__construct() must be an instance of Illuminate\Contracts\Auth\UserProvider, null given, called in E:\vagrant\develop\mcc\vendor\laravel\framework\src\Illuminate\Auth\AuthManager.php on line 125
#0 E:\\vagrant\\develop\\mcc\\vendor\\laravel\\framework\\src\\Illuminate\\Auth\\AuthManager.php(125): Illuminate\\Auth\\SessionGuard->__construct('web', NULL, Object(Illuminate\\Session\\Store))
#1 E:\\vagrant\\develop\\mcc\\vendor\\laravel\\framework\\src\\Illuminate\\Auth\\AuthManager.php(94): Illuminate\\Auth\\AuthManager->createSessionDriver('web', Array)
#2 E:\\vagrant\\develop\\mcc\\vendor\\laravel\\framework\\src\\Illuminate\\Auth\\AuthManager.php(68): Illuminate\\Auth\\AuthManager->resolve('web')
#3 E:\\vagrant\\develop\\mcc\\vendor\\laravel\\framework\\src\\Illuminate\\Auth\\AuthManager.php(54): Illuminate\\Auth\\AuthManager->guard('web')
为什么会走guard('web')捏?不是很清楚求指教
middleware 要写成
auth:api
@ALMAS 是写的auth:api