JWT in the server side is a bad practice. But most of the time we say that in the context when the
API calls are made from the client side.
Currently I am doing an implementation where from my backend I need to generate
JWT token and use in
API calls in the server side itself. (Documentation which I am following (Flipkart))
Here the expiry time of my
JWT will be 1000 seconds (16.67 minutes).
Problem: Where should I store my
JWT once created so that all the multiple client hits use the same
JWT until it expires.
Possible Approaches :
- Store in the database, which I think will be a very bad decision considering it has to renew every 16 minutes.
- Store in the client cookie. But here since its a server to server calls, different client at the same time will have different JWT tokens.
- I am using Magento 1.9, and we can store values in sessions, customer-sessions etc. It has same problem as 2nd.
Thus, I am looking for possible approaches which can be followed in this case.