Skip to content
Discussion options

You must be logged in to vote

Hi there!

Claims are indeed immutable, so if you need to modify an instance for continued re-use later, you'll need to create a new instance based on the previous one. Example:

Claims newClaims = Jwts.claims().add(existingClaims).add(existingClaimName, claimValue).build();

but if you only need to override a few claims for a single JWT, and you don't need a newClaims instance for continued use, you can do it inline when creating the JWT instead:

Jwts.builder().claims(existingClaims).claim(existingClaimName, claimValue)... // etc...

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mparthasarathi
Comment options

Answer selected by mparthasarathi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants