I am working on an integration, where I need to make repetitive calls to another system. As of now, I fetch the Access Token for every call, which is extremely bad, as I make more than 300 calls. Fetching token for each call is expensive.
I wanted to get the access token first and store it till the time the sync is not completed, and afterward, I don't want it to be in the memory.
What would the best and secure way to store the token during this time.
I am thinking of using the below dependency to check whether the token has expired or not, if it is expired then only I want to fetch it again.
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>4.0.0</version>
</dependency>
Is this approach correct? If not could someone please tell me what would be the best way to do it?