Hello Atlassian Community,
I'm encountering an issue while attempting to use the Authorization API within a web trigger function to add comments via the Jira API. Here's a breakdown of the problem and what I'm trying to achieve:
I am developing a web trigger function in Atlassian Forge that needs to add comments to a Jira issue using the Jira REST API (POST /rest/api/2/issue/{issueIdOrKey}/comment
). To ensure the user has permission to add comments, I'm using the authorize
function provided by Atlassian Forge, like so:
const canAddComments = await authorize() .onJiraIssue(issueId) .canAddComments();
However, every time I invoke this authorization step, I encounter the following error:
{ "name": "NEEDS_AUTHENTICATION_ERR", "message": "Authentication required", "serviceKey": "gotoresolve", "options": { "isExpectedError": true }, "status": 401 }
I need assistance in resolving this authentication issue so that my web trigger function can successfully add comments to Jira issues. Ideally, I would like to understand how to correctly authenticate using the authorize
function or, if necessary, how to implement a custom authorization method that checks the current user's permissions before allowing the comment to be added.
Fixing authorize
Function Issue: Is there a specific way to correctly use the authorize
function within a web trigger context to authenticate and authorize actions like adding comments?
Custom Authorization Solution: If using the authorize
function directly is not feasible or appropriate for this context, how can I implement a custom authorization process that checks if the current user has permissions to add comments to a specific Jira issue?
Any guidance, examples, or documentation references that can help me resolve this issue would be greatly appreciated. Thank you in advance for your assistance!
Online 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.