Hi,
I have been trying to expose custom REST API endpoints in my Forge app for some time now, and I can’t figure out how to troubleshoot the issue.
I have followed this documentation step by step: https://developer.atlassian.com/platform/forge/access-rest-apis-exposed-by-a-forge-app/
manifest.yml:
modules:
jira:globalPage:
- key: forge-test-rest-hello-world-full-page
resource: main
resolver:
function: resolver
title: forge-test-rest
routePrefix: hello-world
function:
- key: resolver
handler: index.handler
- key: handler1
handler: index.handler1
- key: handler2
handler: index.handler2
apiRoute:
- key: employee-api-1
path: /employeeName
operation: GET
function: handler1
accept:
- application/json
scopes:
- read:employee:custom
- key: employee-api-2
path: /employeeName
operation: POST
function: handler2
accept:
- application/json
scopes:
- read:employee:custom
- write:employee:custom
resources:
- key: main
path: static/hello-world/build
app:
runtime:
name: nodejs24.x
memoryMB: 256
architecture: arm64
id: ari:cloud:ecosystem::app/xxxxxxx
custom-scopes.yaml
version: 1
scopes:
read:employee:custom:
displayName: Read Employee Info
description: >-
Read employee information such as name, date of joining, etc.
write:employee:custom:
displayName: Edit Employee Info
description: >-
Edit information related to an employee such as name, dob, payroll info, etc.
I have created a new OAuth 2 app in the developer portal and assigned the right scopes:
After generating the refresh token, I then proceeded in getting an access token (following this doc: https://developer.atlassian.com/cloud/confluence/oauth-2-3lo-apps/#2--exchange-authorization-code-for-access-token)
Using this access token, calls made to <jira_api>/oauth/token/accessible-resources return an empty array.
Any API call to my forge app endpoints result in unauthorized:
https://<jira_instance>.atlassian.net/gateway/api/svc/jira/apps/<forgeAppId>_<forgeEnvId>/getEmployeeName
Result:
{
"code": 401,
"message": "Unauthorized; scope does not match"
}
How can I figure out the issue here? I get the same very unhelpful message no matter what I try (even changing the URL randomly to trigger a 404 results in 401).
Thanks!
