我不明白我做错了什么。我无法设置令牌到期时间。
<?php
namespace App\Providers;
class AuthServiceProvider extends ServiceProvider
{
public function boot()
{
$this->registerPolicies();
Passport::tokensExpireIn(Carbon::now()->addDays(1));
Passport::refreshTokensExpireIn(Carbon::now()->addDays(30));
}
}
但是当我打电话时$user->createToken()
,例如这样:
<?php
// as a demo
namespace App\Http\Middleware;
class ParseSpecialToken
{
public function handle($request, Closure $next)
{
$user = User::find(1);
$accessToken = $user->createToken('Some token')->accessToken;
$request->headers->add(['Authorization' => 'Bearer '. $accessToken]);
return $next($request);
}
}
令牌到期仍然是 1 年,而不是 1 天。为什么?如何更改exp时间?