Skip to content

Instantly share code, notes, and snippets.

@rbrooks
Last active September 9, 2016 14:32
Show Gist options
  • Save rbrooks/05a2c428ef3f31221ef79a0942cc8bca to your computer and use it in GitHub Desktop.
Save rbrooks/05a2c428ef3f31221ef79a0942cc8bca to your computer and use it in GitHub Desktop.
// First:
// npm install jsonwebtoken
// https://github.com/auth0/node-jsonwebtoken
//
// Then launch `node` shell.
var jwtLib = require('jsonwebtoken');
var jwtStr = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb250ZXh0Ijoic3N2cHpmYWZoZCIsInN1YiI6InVybjpzd2l0Y2hjb25uZXg6dXNlcjo0MCIsImlzcyI6InVybjpzd2l0Y2hjb25uZXg6c3ZjOmF1dGgiLCJleHAiOjE0NzMzNjMxNTMsImlhdCI6MTQ3MzM2Mjg1MywiYXVkIjoidXJuOnN3aXRjaGNvbm5leDpzdmM6bW9iaWxlIn0.tZj08Vlci3g7SYUm-8MxfH_Ty_1rtBGgUzC311-NSaU';
jwt = jwtLib.decode(jwtStr);
if (jwt.exp < Date.now() / 1000) console.log('JWT token is expired.');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment