I am trying to use the Forge app REST API preview feature with a Confluence Forge app, and I followed all the documented setup steps. The OAuth authorization flow succeeds, and the access token I receive includes the custom scopes I defined in my Forge manifest, such as read:employee:custom and write:employee:custom.
However, when I send a request to the exposed REST API, I get:
401 Unauthorized; scope does not match
Because the token is issued successfully and contains my custom scopes, I suspect the problem may be related to the Forge app scope configuration or the way the required Forge app permissions are being handled in the OAuth 2.0 / 3LO setup.
Maybe it’s because of the step 7, in fact it’s the only missed step in the docs which tells us to add the read:forge-app:confluence scope
It turns out there’s “semi-documented” parameter that clients need to pass when using this feature. The Atlassian developer team thought that users would find the correct URL in the developer console: See this screenshot
For me, the dev console generates this URL for the “Marketplace App” (even though my app is not on Marketplace):
Newlines added for readability. Notice the sns parameter. It’s needed to tie the resulting OAuth token to your specific Forge app installation and it mirrors the URL you would call for for requests:
For reference, see this helper Python code for doing the OAuth dance using the relationship between the URL and the sns parameter: bootstrap-oauth.py
I discussed with the Atlassian team and thought they were going to update the docs. If there isn’t a PR on those docs already, I’ll update myself soon.
I’m seeing an issue with the auto-generated authorization URL for my Forge app. The URL already contains an sns parameter, and I found the related ticket: https://jira.atlassian.com/browse/ECO-1289. According to the docs, the URL should include the scope read:forge-app:confluence, but in my case that scope is missing.
I attempted to add read:forge-app:confluence manually to the authorization URL, but the modified URL did not work. Could the missing read:forge-app:confluence scope be the reason the authorization fails, or is there something else I might be overlooking? Any guidance on why the auto-generated URL omits this scope and how to ensure it’s included would be appreciated.
It’s implicit. And it’s bound to a specific product based on the Forge app’s install context. Hence, I don’t think the developer console can predict which one you need (Jira or Confluence).
To be honest, I’m not sure how those auto-generated URLs are expected to be used. I’ve never seen a client UI where it accepts a whole URL via copy/paste. In my experience, both UI and SDKs require specification of the parts, often because some aspects have to be used in multiple places. For example, the state parameter obviously needs to be filled out by client code, not a human.
In any case, my observation is the URLs need to be “merged”. I frequently use scopes from multiple APIs in 1 client, so I can’t use multiple separate URLs from the developer console.
Could you share the URL you’ve tried? It’s safe because you aren’t sharing the client_secret. And, until you use the “distribution” option, the flow will fail for everyone except you.
Hello Ibuchanan, It works as you described, and the authentication is now being completed correctly.
However, I’m facing two other challenges:
I couldn’t find any way in the docs to extend the expiration time of the access token. Is it possible to customize the access token lifetime, or is it fixed by design?
In the handler for the exposed API, I’m calling invokeRemote, but it fails with a 424 error: Invocation failed for appId: unknown
This happens despite having what appears to be a correct configuration. The same invokeRemote call works in other handlers, such as webtriggers and resolvers, so I suspect the issue may be related to the exposed REST API feature itself.
Correct. Access tokens are intended to be short-lived both in the OAuth spec and for Forge specifically. You should probably look at implementing the refresh flow.