In this article, we would be learning about JWT’s and why you should use them for authorizations.
JSON web token (
JWT is used for AUTHORIZATION, not AUTHENTICATION.
In session based authentication, the user logs in from a client (by posting an email and password to a client), and the server does the authentication. If this is correct, the user is stored in the session, and the session is stored on the
Instead of storing information on the server after authentication, JWT creates a JSON web token and encodes, sterilizes, and adds a signature with a secret key that cannot be tampered with. This key is then sent back to the browser. Each time a request is sent, it verifies and sends the response back.
The main difference here is that the user’s state is not stored on the server, as the state is instead stored inside the token on the client-side.
JWT also allows us to use the same JSON Web Token in multiple servers that you can run without running into problems where one server has a certain session, and the other server doesn’t.
Most modern web applications use JWT for authentication reasons like scalability and mobile device authentication.