dqb78642 2018-11-23 08: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 11: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 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部