-
I had a previous issue #15323 where I was unable to set custom claims by extending Phalcon\Security\JWT\Builder Now I am on the opposite side of the issue where I am receiving a JWT token that contains custom claims and I need to be able to read, validate and use from the token. The only thing I've been able to track down so far is by using getClaims() on a token object after parsing the original JWT string, but that unfortunately is protected and the decodeClaims() method in phalcon/Security/JWT/Token/Parser.zep is set as private rather than protected. Is there any way I can read custom claims from a JWT token in Phalcon? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Answered my own question: For those who are curious, you have to set Example: $tokenObject = $parser->parse($tokenReceived);
$claims = $tokenObject->getClaims();
if($claims->get('claim_name') !== NULL) {
echo 'Claim Exists!';
} else {
echo 'Claim does not exist.';
} |
Beta Was this translation helpful? Give feedback.
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: