node.js に jsonwebtoken パッケージを使用しています。
そのようなトークンを作成します:
var token = jwt.sign(user, tokenSecret, {expiresInMinutes: 1});
そのように確認します:
jwt.verify(token, tokenSecret, function(err, decoded) {
if(err) return done(new Error('Invalid authentication!'));
if(!decoded) return done(null, false);
return done(null, decoded, { scope: 'all'});
});
ただし、トークンが期限切れになることはありません(「リクエスト」の間に数分待ちました)。