dqb78642 2018-11-23 16:38
浏览 109
已采纳

Laravel 5.4 Passport-API无法设置30天到期令牌

I am Using Laravel 5.4 Passport Authentication. I have a problem to set API token expire date for 30 days. I have tried given code in Laravel documentation but it's not working. In the database, it's showing one year default token expiration date.

I have used

public function boot(){

    $this->registerPolicies();

    Passport::routes();

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

}

if there is any solution please suggest me.

Thanks

  • 写回答

1条回答 默认 最新

  • duansao6776 2018-11-23 19:58
    关注

    i also got same issue so.. i used like that

    try to change directly in PassportServiceProvider.php

    go to PassportServiceProvider.php path should be like this

    projectName/vendor/laravel/passport/src/PassportServiceProvider.php
    

    and fine this line

    new PersonalAccessGrant, new DateInterval('P1Y')
    

    for example set expiry 1 month then

    new PersonalAccessGrant, new DateInterval('P1M')
    

    for example set expiry 1 week then

    new PersonalAccessGrant, new DateInterval('P1W')
    

    for example set expiry 5 DAYS then

    new PersonalAccessGrant, new DateInterval('P5D')
    

    for more DateInterval see

    github issue see

    stackoverflow question see

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 运动想象脑电信号数据集.vhdr
  • ¥15 三因素重复测量数据R语句编写,不存在交互作用
  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目