Register or Login to Your Account
How to store token in cache in rest api?
It's against rest api principles, the client should store the token and send it inside every api call
i agree! learn more about token interception in frontend
No need to store token in cashe just create singleton class with method which wil return the token and call it after login
Indeed. A singleton and resend in a bearer header on every call.
could you please share any blog or reference ? Thanks.
Good example: https://blog.joaograssi.com/typed-httpclient-with.../ It doesn't illustrate a singleton, but it uses a messagehandler to "handle" all your token requirements. Also note that your token has a lifetime you can check so there is no need to get a new token on every call, hence the "caching". Also note that when you are working with tokens that there is a difference between JWTokens and Reference tokens where the latter is only a reference to the token payload in your datastore. The advantage of the latter is that you can "revoke" the token by simply deleting the token payload from your datastore. With a JWT once it is delivered, you cannot take it back and it is valid until its validity has run out.
Search for MemoryCache
Use coding.Use Redis Cache
U must use http secure cookies from the response, Easy ... store it in local storage pull it out to use it ... with every call send it to server .... jwt..