-6ren">
gpt4 book ai didi

php - Auth guard 驱动程序 [api] 未定义

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:49:17 25 4
gpt4 key购买 nike

我正在使用 laravel 5.4 并使用 jwt authjwt 版本是 jwt-auth "tymon/jwt-auth": "0.5.*"

在 auth.php 中我有

'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],

'api' => [
'driver' => 'jwt',
'provider' => 'users',
],
],

在 Api.php 中我有

 Route::post('/login','HomeController@authenticate');


Route::group(['prefix' => 'v2','middleware' => 'auth:api',], function () {

// Authentication Routes...
Route::get('/logout','HomeController@logout');
Route::get('/home','HomeController@home');

});

当我从 postman 那里邮寄电子邮件和密码时,它将返回 token 。

当我尝试访问时

http://localhost/demo/public/api/v2/home

和标题我通过了授权不记名 token

我在 postman 中收到以下错误

Whoops, looks like something went wrong. (1/1) InvalidArgumentException Auth guard driver [api] is not defined. in AuthManager.php (line 99) at AuthManager->resolve('api') in AuthManager.php (line 70) at AuthManager->guard('api') in Authenticate.php (line 61) at Authenticate->authenticate(array('api'))

能帮我解决一下吗

我还检查了自 2016 年 9 月 27 日以来的旧问题 https://github.com/tymondesigns/jwt-auth/issues/860

最佳答案

尝试设置 token :

'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],

'api' => [
'driver' => 'token', // here !
'provider' => 'users',
],
],

关于php - Auth guard 驱动程序 [api] 未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44465581/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com