Laravel Passport token lifetime

前端 未结 10 1344
轮回少年
轮回少年 2021-01-04 01:12

I don\'t get what I\'m doing wrong. I can\'t set token expiration time.



        
10条回答
  •  一生所求
    2021-01-04 01:56

    Here are the methods used to update expiration time for all the grant types :

    Personal access token:

    public function boot(){
            $this->registerPolicies();
    
            Passport::routes();
            Passport::personalAccessTokensExpireIn(Carbon::now()->addHours(24));
            Passport::refreshTokensExpireIn(Carbon::now()->addDays(30));
    }
    

    Rest all

    public function boot(){
            $this->registerPolicies();
    
            Passport::routes();
            Passport::tokensExpireIn(Carbon::now()->addHours(24));
            Passport::refreshTokensExpireIn(Carbon::now()->addDays(30));
    }
    

    Just update the above code in the boot method of AuthServiceProvider.

提交回复
热议问题