Trying read all sprints, got Authentication required error for workflowPostFunction module, but not for customField module

I got an authentication message when trying to get the sprints in Forge app using jira:workflowPostFunction module.

message: ‘Authentication required’,
name: ‘NEEDS_AUTHENTICATION_ERR’,
stack: ‘’

The RESTApi to read the sprint is:
/rest/agile/1.0/board/{boardId}/sprint.

In the forge app, the function to call the restapi is:
api.asUser().requestJira(…);

In manifest file, permissions used are:

- manage:jira-configuration
- read:jira-work
- read:jira-user
- read:sprint:jira-software

The Forge app is executed when running the issue’s transition, and then got the message mentioned above in the forge logs.

I have the same Forge app but using jira:customField module. All are the same as above, but I did not got the authentication message, the customField is able to get all sprints.

I am always using administrator level account for my development.
I understand that the restapi is required OAuth2.0.

But why jira:customField module did not got any error but the jira:workflowPostFunction?

This is the line to call the restapi I used for both apps:

const response = await api.asUser().requestJira(
      route`/rest/agile/1.0/board/${rdBoard.Id}/sprint`,
      {method: 'GET', headers: {'Accept': 'application/json'}}
);

If I have to use 'Authorization': 'Bearer <access_token>' in the header, whose token should I use? my administration token? or atlassian-addons-project-access?

Thanks.

@BennyChandra,

Odd. I confirm that you have the scopes specified for running a post function event. And, the payload indicates that it should have a user context for asUser. So I don’t see anything wrong with what you’re trying to do. Maybe some additional console.log messages about the event would help us diagnose.

Short answer, you can’t. The requestJira method will effectively strip that header. And trying through a manually constructed fetch will not let you access Jira. At least, last time I checked, you can’t treat Atlassian infrastructure as an external target.