當(dāng)我為我的控制器使用 auth api guard 時(shí),我面臨以下異常未定義身份驗(yàn)證保護(hù) [api]當(dāng)我在請求標(biāo)頭中刪除授權(quán)時(shí),我的控制器工作是正確的,但是當(dāng)我添加授權(quán)并接受請求標(biāo)頭時(shí),我收到此錯(cuò)誤。我的路線:Route::group(['prefix' => 'category','middleware' => 'auth:api'], function () { Route::post('add', 'Api\CategoryController@addCategory'); Route::post('edit', 'Api\CategoryController@editCategory'); Route::get('get/{id}', 'Api\CategoryController@getCategory'); Route::get('get', 'Api\CategoryController@getCategory'); Route::get('delete', 'Api\CategoryController@deleteCategory');});auth.php 文件: 'guards' => [ 'web' => [ 'driver' => 'session', 'provider' => 'users', ], 'api' => [ 'driver' => 'passport', 'provider' => 'users', 'hash' => false, ],],我將 Passport::routes() 添加到 AuthServiceProvider.php 并遷移了護(hù)照遷移并安裝了護(hù)照以創(chuàng)建護(hù)照客戶端訪問我認(rèn)為一切都很好,但會(huì)出錯(cuò)
1 回答

Helenr
TA貢獻(xiàn)1780條經(jīng)驗(yàn) 獲得超4個(gè)贊
您需要清除配置緩存才能生效。對于 Unauthenticated 這意味著令牌無效或未正確傳遞
https://laravel.com/docs/5.7/passport#passing-the-access-token
- 1 回答
- 0 關(guān)注
- 341 瀏覽
添加回答
舉報(bào)
0/150
提交
取消