Creating Tokens
The next step is to define the functions to create and read JWT. Since the JWT used for the Helping Hands application uses JWE to encrypt the claims, it is OK to add both user ID and roles information within the payload that can be later retrieved from a valid token to authorize the user.
The create-token and read-token functions shown in the following example provide a way to create a JSON Web Token and read an existing one, respectively. The create-token function uses a utility function—create-payload—to create the claim set and the payload of JWT. Claim sets that are relevant for the current example are issueTime that defines the epoch time of when this token was created, expirationTime that sets the time beyond which the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access