firebase / php-jwt

PHP package for JWT
BSD 3-Clause "New" or "Revised" License
9.38k stars 1.27k forks source link

Can not decode EXP token, is there a way? #536

Closed russmenum closed 9 months ago

russmenum commented 1 year ago

I have a case where I need to read the body of an EXP token

$decoded = JWT::decode($todecode, Security::salt(), array_keys(JWT::$supported_algs));

this works when the token is active, but after it expires it creates a server-side error

Error: [Firebase\JWT\ExpiredException] Expired token (...files/vendor/firebase/php-jwt/src/JWT.php:158)

Is there a way to still get the result of the decode in spite of the error for an old expired token? I just need to be able to read the contents not use it for validation.

Wedrix commented 1 year ago

@russmenum I also have a similar use-case. Luckily, it seems #521 has been approved so hopefully we should get a workaround soon. This allows you to get the payload from the exception and use it.

talandaw commented 11 months ago

To add to this, if you're using PHP 7.2 (which looks like support wasn't officially dropped for) then you'll be unable to create the ExpiredException with these changes.

saranshdhingra commented 9 months ago

Hi @russmenum Given that this functionality was added in v6.9.0, hopefully this resolves your issue.

Closing this for now, but please feel free to reopen if the issue is still not resolved.

Thanks.