firebase/php-jwt

Can not decode EXP token, is there a way?

russmenum opened this issue · 3 comments

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.

@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.

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.

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.