Dear Atlassian Support Team,
I am developing a Confluence Cloud macro using Express.js and atlassian-connect-express. The macro is functioning correctly for most customers; however, I have encountered an issue where, for some customers, the client key is not retrieved correctly.
When multiple customers trigger requests simultaneously, the client key appears to be overwritten by the client key of the last customer who made a request. As a result, API calls that rely on the client key for authentication and data retrieval fail for some customers.
Below is a simplified version of my implementation, where I store the client key in a global variable for use in subsequent API calls:
var Globlas_Clientkey = '';
app.get('/configure', addon.authenticate(), function (req, res) {
Globlas_Clientkey = req.context.clientKey;
addon.settings.get('configuration', req.context.clientKey).then(function (configObject) {
if (configObject && configObject.clientKey) {
if (configObject.clientKey !== req.context.clientKey) {
console.log(`Mismatch in client key: Expected ${req.context.clientKey}, Retrieved ${configObject.clientKey}`);
configObject = null;
}
}
res.render('configure', { configObject });
});
});
app.post('/configure', addon.checkValidToken(), function (req, res) {
Globlas_Clientkey = req.context.clientKey;
let configObject = req.body;
configObject.clientKey = req.context.clientKey;
addon.settings.set('configuration', configObject, req.context.clientKey).then(() => {
res.send(configObject);
});
});
app.post('/GetRepositories', async function (req, res) {
try {
let Baseurl = req.query.xdm_e;
let APIEndPoint = `/api/externalintegration/GetRepositories?EmailId=${req.body.userid}`;
const APIResponse = await AsyncProlGetAPI(APIEndPoint, req.body, Baseurl, Globlas_Clientkey, 0);
res.send(APIResponse);
} catch (e) {
console.error("Error occurred:", e);
res.status(500).json({ error: 'An error occurred' });
}
});
I am unable to access the correct clientKey inside the /GetRepositories API.
Since this API does not use addon.authenticate(), how can I reliably retrieve the correct clientKey for the requesting customer?
What is the recommended approach for handling the clientKey in a multi-customer environment using atlassian-connect-express?
Are there library features that provide a reliable way to retrieve and manage the client key across API calls?
Thank you for your assistance. I look forward to your response.
Best regards,
Prolaborate Team
Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.
Register NowOnline forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.