令牌过期不起作用 - Sanctum,Laravel

Token expiration doesn't working - Sanctum, Laravel

我做了什么:

我通过在 sanctum.php 文件中将 null 更改为 1 分钟 expiration 来向具有登录系统的应用程序添加令牌过期:

/*
|--------------------------------------------------------------------------
| Expiration Minutes
|--------------------------------------------------------------------------
|
| This value controls the number of minutes until an issued token will be
| considered expired. If this value is null, personal access tokens do
| not expire. This won't tweak the lifetime of first-party sessions.`enter code here`
|
*/

'expiration' => 1,

问题:

它不起作用,该应用程序仍然始终接受授权请求。什么都没有改变。


代码:

$tokenResult = $user -> createToken('authToken') -> plainTextToken;
return response() -> json([
  'status_code' => 200,
  'access_token' => $tokenResult,
  'token_type' => 'Bearer',
]);
Route::group(['middleware' => 'auth:sanctum'], function () {
  
   [Routes]

 });
 Auth::user()->tokens()->delete();          
 return response()->json([
     'status_code' => 200,
 ]);

您可能需要清除配置缓存。尝试在您的终端运行 php artisan config:clear