I’m trying to use the authorize API from within a function that was called by an async event queue. The authorize function works just fine a synchronize resolver function. The overall goal is to make sure the user has view permissions on a set of issues returned by a jql query. Running the JQL query in the original synchronous resolver is sub-optimal b/c the query result may be several thousand issues and there’s downstream processing that must occur, which is why I’m using an asynchronous event queue to do the processing.
Here’s the code
const response = await authorize().onJira([{
permissions: ['BROWSE_PROJECTS'],
issues: batchIds
}]);
The exception is
PROXY_ERR: Forge platform failed to process runtime HTTP request - 401 - AUTH_TYPE_UNAVAILABLE
at handleProxyResponseErrors (webpack://jira-dashboard-gadget-custom-ui/node_modules/@forge/api/out/api/fetch.js:83:1)
at <anonymous> (webpack://jira-dashboard-gadget-custom-ui/node_modules/@forge/api/out/api/fetch.js:28:1)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
status: 401,
errorCode: 'AUTH_TYPE_UNAVAILABLE'
I have also tried calling the below
const requestBody = {
accountId: userAccountId,
projectPermissions: [{
permissions: ["BROWSE_PROJECTS"],
issues: batchIds,
projects: [10039]
}]
};
this.logger.info('Permission check request body:', JSON.stringify(requestBody, null, 2));
const response = await api.asUser().requestJira(route`/rest/api/3/permissions/check`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(requestBody)
});
const result = await response.json();
this.logger.info(`Permission check response status: ${response.status} ${JSON.stringify(result, null, 2)}`);
if (!response.ok) {
this.logger.error(`Permission check failed with status: ${response.status}`);
return false;
}
This call only runs when you use asUser. It will not work with asApp irrespective of whether it’s called from a synchronous resolver or an async resolver. You cannot seem to use asUser within an async event resolver either.
Suggestions?