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!
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Hi @sai_charanAr
Store the token in the shared JCR repository (e.g., under /var/myproject/token), which is accessible by all instances.
Views
Replies
Total Likes
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
Views
Replies
Total Likes
@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
Views
Replies
Total Likes
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
Views
Replies
Total Likes
@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.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies