Skip to content

How to read custom claims from a JWT token? #15577

Answered by JMoodyFWD
JMoodyFWD asked this question in Q&A
Discussion options

You must be logged in to vote

Answered my own question:

For those who are curious, you have to set getClaims() first, then access specific claims by using ->get('claim_name');

Example:

        $tokenObject = $parser->parse($tokenReceived);

        $claims = $tokenObject->getClaims();

        if($claims->get('claim_name') !== NULL) {
            echo 'Claim Exists!';
        } else {
            echo 'Claim does not exist.';
        }

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by JMoodyFWD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant