skip to Main Content

I needed a token that will never expire i.e it will have a lifetime validity. So, I changed the following in jwt.php file in config folder.

'ttl' => env('JWT_TTL', null),

But after this action I started getting erros saying: TymonJWTAuthExceptionsTokenInvalidException: JWT payload does not contain the required claims in file apiTest/vendor/tymon/jwt-auth/src/Validators/PayloadValidator.php on line 65.

2

Answers


  1. Chosen as BEST ANSWER

    This issue is occuring because required_claimsis expecting the exp. So just remove exp key from your config/jwt.php's required_claims array like.

        'required_claims' => [
        'iss',
        'iat',
        // 'exp',  
        'nbf',
        'sub',
        'jti',
    ],
    

    In my case I just commented the exp line and this will solve the problem.

    A issue was created on github regarding this issue. You can find it here. Here you will get solution to this problem and similar problems.


  2. Steps for not expiring login in JWTAuth:

    1. Open jwt.php in config folder (if it not available then publish the jwt.php file using this command in project==>

    php artisan vendor:publish --provider="TymonJWTAuthProvidersJWTAuthServiceProvider" )

    1. Change

    'ttl' => env('JWT_TTL', 60),
    to

    'ttl' => env('JWT_TTL', null),

    1. remove exp in this line:-

    'required_claims' => [ 'iss', 'iat', 'exp', 'nbf', 'sub', 'jti', ],

    1. After this fire this command on terminal inside your project
    php artisan optimize:clear
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search