Wednesday, August 28, 2019

Laravel Passport Access Token Expire Lifetime

No comments
In this post, we will learn how to set lifetime expiration time of passport access token in laravel. we can set personal access token expiry time longer and also event shorter using tokensExpireIn, refreshTokensExpireIn, and personalAccessTokensExpireIn methods.
we can increase token expire time of access token using tokensExpireIn(). we can increase refresh token expire time of access token using refreshTokensExpireIn(). we can increase personal access token expire time of access token using personalAccessTokensExpireIn().
Let's see bellow example to set longer time of expire access token in laravel 5 application.
Example 1: app/Provides/AuthServiceProvider.php

registerPolicies();

   

        Passport::routes();

        Passport::tokensExpireIn(now()->addDays(30));

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

        Passport::personalAccessTokensExpireIn(now()->addDays(30));

    }


}