Validate claims during decoding
masterYou can verify that a decoded JWT matches a trusted set of claims by passing a JWTClaimsSet to the .claimsSet() method during decoding. After calling .decode, check the jwtError property on the builder to see if validation failed.
// Trusted Claims Set
JWTClaimsSet *trustedClaimsSet = [[JWTClaimsSet alloc] init];
trustedClaimsSet.issuer = @"Facebook";
// ... set other properties
NSString *message = @"encodedJwt";
NSString *secret = @"secret";
NSString *algorithmName = @"chosenAlgorithm";
JWTBuilder *builder = [JWTBuilder decodeMessage:message].secret(secret).algorithmName(algorithmName).claimsSet(trustedClaimsSet);
NSDictionary *payload = builder.decode;
if (builder.jwtError == nil) {
// Success: claims matched
} else {
// Error: claims did not match or decoding failed
}