Hi everyone,
In our AEM as a Cloud Service project, we are generating an **access token inside an OSGi service class**. Every time we call the method in this service, it generates a **new token**.
The requirement is:
* The token should be **generated only once every 24 hours**
* The same token should be **reused across all publish instances** within that 24-hour window
Since AEM as a Cloud Service is **stateless** and each publish instance runs independently, using in-memory storage or static variables doesn’t help — the token is regenerated on every call from different instances.
Is there any feasible or recommended way to store and share this token across all publish instances in AEM as a Cloud Service?
Looking for a lightweight, cloud-compatible solution. Appreciate any guidance!
Thanks!
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Hi @kautuk_sahni @Aditya_Chabuku , we have used adobe io to store and chache the token for required time please find the article attached we have documented the process in this
https://medium.com/@nagarajuminda9/secure-ims-token-management-using-adobe-i-o-runtime-and-adobe-sta...
Thank you all for you responses ,which help a lot to derive the solution
Hi @sai_charanAr
Store the token in the shared JCR repository (e.g., under /var/myproject/token), which is accessible by all instances.
Hi @Karishma_begumSh ,is it recommended update the repository in publisher even if we save (var/myproject/token ) how we can sync with multiple publisher ?
Views
Replies
Total Likes
No, it is not recommended to write to the JCR repository from publish instances, even under /var, especially in AEM as a Cloud Service because as it is stateless it allows only to read.
instead use external token store or use shared token generator service
@sai_charanAr I would recommend you to develop this api outside of aem like in Adobe io Runtime or any other middleware api where access token is generated and calls external service or any other operation post that.. and you call adobe io runtime/middle layer api from your publisher everytime
Hi @sai_charanAr ,
We have to store outside AEM like Redis Cache of Azure/ AWS.
Our design was based on 2 level of cache mechanism to avoid call to external API each time.
This way were able to achieve the desired functionality in efficient manner.
Thanks
Hi @sai_charanAr ,
External Token Store with Local Cache
Summary
1 . Use an external shared store (e.g., Redis, AWS SSM, Azure Key Vault, or S3/Blob).
2. Each AEM publish instance:
- First checks local memory (e.g., Guava cache).
- If not found, fetches from the external store.
- If expired or not present in store, one instance regenerates the token and stores it.
3. Use OSGi Scheduler or lazy-load logic to regenerate every 24h.
Regards,
Amit
@sai_charanAr Store it in jcr node and maintain sticky session to read value from specific publishers.
Views
Replies
Total Likes
Hi @sai_charanAr ,
Is there any update on this problem? If so, please let the community know.
@sai_charanAr Did you find the suggestions helpful? If you need more information, please let us know. If a response resolved your issue, kindly mark it as correct to help others in the future. Alternatively, if you discovered a solution on your own, we'd appreciate it if you could share it with the community. Thank you.
Views
Replies
Total Likes
Hi @kautuk_sahni @Aditya_Chabuku , we have used adobe io to store and chache the token for required time please find the article attached we have documented the process in this
https://medium.com/@nagarajuminda9/secure-ims-token-management-using-adobe-i-o-runtime-and-adobe-sta...
Thank you all for you responses ,which help a lot to derive the solution
Views
Likes
Replies