Fix "JWT payload does not contain the required claims" in Laravel

Joe Vallender • March 30, 2021

tl;dr remove exp claim when disabling TTL

A quick post about configuring the tymon/jwt-auth package in Laravel.

It's a fairly common use case to set the JWTs to never expire, and then manually expire them if necessary.

You might set JWT_TTL=null in your .env file, or 'ttl' => null in config/jwt.php.

If you make that change, the next time you try to generate a JWT you will get the error "JWT payload does not contain the required claims".

To fix it, you need to remove the 'exp' claim in config/jwt.php because that claim requires a numeric TTL.

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