Hi @saiful1991,
Thank you for your patience.
After carefully going through our Action Limitations documentation, I noticed that it makes note that the cumulative size of cached keys and their values must not exceed 8192 bytes.
Given that, one way to make this work is to use a few cache (key, value) pairs to store the Management API Token.
Because Cache Keys are limited to 2048 bytes, we can make this work with 3 Cache items.
I have tested this myself and got it to work with the following:
const management = new ManagementClient({
domain: event.secrets.domain,
clientId: event.secrets.clientID,
clientSecret: event.secrets.clientSecret,
audience: event.secrets.audience,
tokenProvider: {
enableCache: true,
cacheTTLInSeconds: 86400
}
});
//Get new access token and set it in cache
const newToken = await management.getAccessToken();
api.cache.set('first',newToken.slice(0,2048))
api.cache.set('second', newToken.slice(2048,4096))
api.cache.set('third', newToken.slice(4096))
//Get the new Cached Token
const getNewToken = api.cache.get('first').value + api.cache.get('second').value + api.cache.get('third').value
console.log(getNewToken)
I hope this helps!
Please reach out again if you have any additional questions.
Thank you,
Rueben