Expand my Community achievements bar.

Submissions are now open for the 2026 Adobe Experience Maker Awards.
SOLVED

Feasible Way to Share Token Across All Publishers in AEM as a Cloud Service?

Avatar

Level 2

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

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Level 2

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 

View solution in original post

10 Replies

Avatar

Level 4

Hi @sai_charanAr 
Store the token in the shared JCR repository (e.g., under /var/myproject/token), which is accessible by all instances.

Avatar

Level 2

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 ?

Avatar

Level 4

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

Avatar

Community Advisor

@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

Avatar

Community Advisor

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.

  • Put token ( data ) in Gauva cache(in memory) and Azure redis cache
  • While checking(accessing), first check in OSGI / Gauva Cache in the AEM itself
  • If it is not present in AEM check in the external(Azure Redis cache)

This way were able to achieve the desired functionality in efficient manner.

 

Thanks

Avatar

Community Advisor

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

Avatar

Community Advisor

@sai_charanAr Store it in jcr node and maintain sticky session to read value from specific publishers.

Avatar

Community Advisor

Hi @sai_charanAr ,

 

Is there any update on this problem? If so, please let the community know.

 

 

Thanks,

Aditya Chabuku

Avatar

Administrator

@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.



Kautuk Sahni

Avatar

Correct answer by
Level 2

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