Skip to content

Instantly share code, notes, and snippets.

@aarongeorge
Last active November 2, 2019 08:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aarongeorge/bca875a0fc622f2eb8cd149590ad7c76 to your computer and use it in GitHub Desktop.
Save aarongeorge/bca875a0fc622f2eb8cd149590ad7c76 to your computer and use it in GitHub Desktop.
Example of a JWT Payload with all Registered Claims
const timeNow = new Date()
const payload = {
iss: 'http://backend.com', // Issuer - Identifier of who provided this JWT
sub: 'uniqueIdOfUser', // Subject - Who is supposed to be using this JWT (The value should mean something for `aud`)
aud: ['http://frontend.com', 'http://backend.com'], // Audience - Who should be consuming this JWT
exp: new Date(new Date(timeNow).setDate(timeNow.getDate() + 7).getTime(), // Expiration Time - When this JWT should no longer be accepted by the `aud`
nbf: timeNow.getTime(), // Not Before - When this JWT should start being accepted by the `aud`
iat: timeNow.getTime(), // Issued At - When this JWT was issued
jti: 'uniqueIdForThisJWT' // JWT ID - Unique ID that the `aud` can use to blacklist/whitelist the JWT even if `exp` and `nbf` requirements are met
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment