Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
russmenum opened this issue Sep 25, 2023 · 3 comments
Closed

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

russmenum opened this issue Sep 25, 2023 · 3 comments
Assignees

Comments

@russmenum
Copy link

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
Copy link

Wedrix commented Oct 3, 2023

@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
Copy link

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 saranshdhingra self-assigned this Dec 27, 2023
@saranshdhingra
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants