Confused resolution to NEEDS_AUTHENTICATION_ERR

jbell
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 22, 2024

Seven months ago, we successfully deployed a custom application to our Jira product. It is a relatively simple jira:issuePanel module that enables some software development workflows on some select jira issues.

Recently, the application started to fail. Some users did not have an issue, others did. One user with two accounts saw consistent failures with one account but not the other.

Last week I checked my development environment and also found that the app was failing for me.

On investigation it was realized this code was the issue:

        response = await api.asUser().requestJira(route`/rest/api/3/myself`, {

          headers: {

            'Accept': 'application/json'

          }

        }),

        result = await response.json();

For users with the issue, result contained the following:

{

  "error": {

    "message": "Authentication required",

    "name": "NEEDS_AUTHENTICATION_ERR",

    "serviceKey": "atlassian-token-service-key"

  }

}

To be clear for many months there were no issues. But this error selectively appears for some users only.

FYI permission scopes in the manifest were:

    - read:jira-user

    - read:jira-work

    - storage:app

An online search of this error code yielded interesting discussions, but no resolution.

The online documentation (https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-myself/#api-rest-api-3-myself-get) shows exactly what was implemented, and the recommended scope (read:jira-user)

One discussion thread suggested this was an issue with the Atlassian servers, so I waited a few days to see if the issue resolved itself. It did not.

Today I explored the documentation more and found this page: https://developer.atlassian.com/platform/forge/manifest-reference/scopes-forge/

It suggested three more scopes that on a whim I tried in my development environment:

    - read:app-system-token

    - read:app-user-token

    - report:personal-data
After deploying and upgrading (in development) with the new scopes the issue was resolved.
Not being sure which of these scopes resolved the issue, I removed them one by one. Each time the application continued to work even after ALL these scopes were removed. I.e. the manifest was now identical to when it was failing, but temporary use of these scopes seemed to reset something.
** Very confused **
For production we decided to included all these scopes. After updating the issue was NOT resolved in the production system.
** Very confused **
One last thing I tried in production - as a user - was to click on the top right user icon (profile and settings), click on manage account, and click on connected apps. The custom application was there. I clicked on the 'Remove' button to remove the app permission for my personal account.
I then went back to the Jira application and opened one of the tickets, which I hoped would reactivate the custom app. It did, and it WAS WORKING!!
I asked someone else who had this issue to go through these steps, and it worked for them also.
** Very confused and a bit worried**
Questions:
- is the issue permanently resolved, or is whatever we did temporary?
- which of the above steps actually resolved the issue?

Many thanks for your help here!

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events