This conversation has been locked due to inactivity. Please create a new post.
This conversation has been locked due to inactivity. Please create a new post.
Hi All,
We have a Rest API Integration with AEM and Before Hitting the actual API we hit a API which generates a Token and Token needs to be passed to actual API to get the Response.
So first time once API is hit to get the token ,token is valid for 10 minutes so within 10 min same token should be used for all the API's and should be saved Server Side.
What is the best way to store the Token in AEM at server Side.
Do we need to use any Java Cache like (Ehcache) or what is the correct approach to handle such sceanrios.
Thanks in Advance.
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @Sb2512 ,
I would use JavaBean which adhere to an extremely simple coding convention to cache response.
public interface Response { String getToken(); }Implementation
public class TokenResponse implements Response { public String getToken() { if (null != this.getToken) { return this.getToken(); } return null; } }Invoking
TokenResponse tokenResponse = callYourHttpAPI(); if (null ! = tokenResponse { //Do Something (Call to 2nd API by passing tokenResponse as a param) .......... }
Hope that helps!
Regards,
Santosh
Hi Arun,
Thanks for the reply...
If there are multiple publish instance how the token will be synced....
Any thoughts @arunpatidar
Hi @Sb2512 ,
I would use JavaBean which adhere to an extremely simple coding convention to cache response.
public interface Response { String getToken(); }Implementation
public class TokenResponse implements Response { public String getToken() { if (null != this.getToken) { return this.getToken(); } return null; } }Invoking
TokenResponse tokenResponse = callYourHttpAPI(); if (null ! = tokenResponse { //Do Something (Call to 2nd API by passing tokenResponse as a param) .......... }
Hope that helps!
Regards,
Santosh