How to Authenticate Nodejs API with JSON Web Tokens

Posted By : Ankit Uniyal | 30-Nov-2018

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

 

JWT

About Author

Author Image
Ankit Uniyal

Ankit has knowledge in Javascript, NodeJS, AngularJS and MongoDB also have experience in using AWS Services.

Request for Proposal

Name is required

Comment is required

Sending message..