Posted by Ankit Uniyal | Last Updated: 07-Jan-19
In this blog, we are going to discuss how to authenticate Nodejs API with JSON Web Tokens. But before going further, let's break it down what is JSON Web Token.
1. Open Standard(RFC 7519).
2. Securely transfer information between any two bodies i.e any two users, any two servers.
3. Digitally signed - information is verified and trusted. There is no alteration of data between the transfer.
a.It is so compact, you can send via URL, POST request, HTTP header.
b.It is supremely fast i.e Fast Transmission and it makes JWT extremely usuable.
It means JWT token itself contains the information about the user. Avoiding query the database more than once.
i.e for example: Suppose you have logged in or the user logged in one time, you verified the credentials and you just provided the token. Now, on every other time, the user request something from your website so he don't have to login as he just have to pass the token and the JWT system will just verify the token and if passes then give the infrmation and respond to that request.
Thus, the case of Self-container. A single has everything in it.
Why JWT is Useful?