· 6 years ago · Feb 25, 2019, 04:26 PM
1api.post('/api/login', (req, res) => {
2
3var secretKey;
4
5require('crypto').randomBytes(48, function(err, buffer) {
6 secretKey = buffer.toString('hex');
7
8 //Create JWT and Secret Key
9 jwt.sign({user}, secretKey, {expiresIn: '30s'}, (err, token) => {
10 res.json({
11 access_token : token,
12 secret_key : secretKey
13
14 });
15 });
16
17
18});
19
20{
21"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImlkIjoxLCJ1c2VybmFtZSI6ImV4YW1wbGV1c2VyIiwiZW1haWwiOiJleGFtcGxlQGdtYWlsLmNvbSJ9LCJpYXQiOjE1NTExMTE1ODAsImV4cCI6MTU1MTExMTYxMH0.aSTVC-HcEdrH1KBNtuD_MoLZ8DWnSiM6bCqO4EgJ5zM",
22"secret_key": "2e6a98abb5b23339ad14601d3bedc1d23847498cb18daf8cfc98c2a2095ec8f47d80053f6d4e22b8f6419407ac3083dc"}