Created
February 2, 2016 14:32
-
-
Save arieljannai/1a89b8e2fb5ad6f611a8 to your computer and use it in GitHub Desktop.
generates a JWT token
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var jwt = require('jsonwebtoken'); | |
module.exports = { | |
getJwtToken : function(issuer, secret) { | |
var issuedAt = Math.floor(Date.now() / 1000); | |
var payload = { | |
iss: issuer, | |
jti: Math.random().toString(), | |
iat: issuedAt, | |
exp: issuedAt + 60, | |
}; | |
var token = jwt.sign(payload, secret, { | |
algorithm: 'HS256', | |
}); | |
return token; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment