Monday, 25 January 2016

Nodejs working with JWT (JSON Web Token)

npm install jsonwebtoken

var jwt = require('jsonwebtoken');

var auth = {
    id : id,
    name : 'moin',
    email : 'mastermoin409@gmail.com',


var token = jwt.sign({ authToken: auth }, 'shhh.....', {expiresIn : 1800});


'shhh.....' is private key or secret key of your application, it is normally string

1800 is  token expiry time

More about API : https://github.com/auth0/node-jsonwebtoken
        

4 comments:

  1. Thank you very much for this wonderful information. I hope so many people will be aware of it and helpful too. And please continue to update like this.
    Node JS Online training
    Node JS training in Hyderabad

    ReplyDelete