Mehrud
Mehrud

Reputation: 201

Laravel Passport: Is it possible to set expire_at for each access_token separately?

Laravel Passport does set expire_at for access tokens via

Passport::tokensExpireIn(Carbon::now()->addDays(15));

Passport::refreshTokensExpireIn(Carbon::now()->addDays(30));

in boot method of AuthServiceProvider

But I want to set expire_at for each access_token separately.

Is there any way to do so in Laravel Passport?

Upvotes: 2

Views: 763

Answers (2)

Moe Far
Moe Far

Reputation: 2752

You can easily add this line above your code:

Passport::tokensExpireIn(YOUR_CUSTOM_TIME);

But remember to change it back after that, because expires_at is a static variable.

Upvotes: 1

Ohgodwhy
Ohgodwhy

Reputation: 50798

You can use DB::table('oauth_access_tokens') and update the expires_at yourself without Passport doing anything for you.

Just add your ->where statements to the query builder to target the tokens you want, and update accordingly.

Upvotes: 3

Related Questions