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.
JWT is:
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.
4. Compact:
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.
5. Self-contained:
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?
1.Authentication
2.Information Exchange
More From Oodles
Ready to innovate? Let's get in touch
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Ankit Uniyal
Ankit has knowledge in Javascript, NodeJS, AngularJS and MongoDB also have experience in using AWS Services.