Unable to fetch spaces asApp

Hi,

While fetching spaces for a globalPage Forge app, I cannot seem to get the spaces while using asApp, when changing to asUser it works without issue, but then I do not get all results I would like (since it considers user permissions).
asApp:
asApp
asUser:
asUser

Simple fetch method:
image

I tested the fetch on multiple instances, which gave different results, for one instance it will return the spaces, for the other, I receive an empty result. I would expect the asApp to return all spaces in the instance.

I have been looking at the Confluence permissions to see if some kind of access is required for the asApp, but I cannot seem to find any (app) user to provide it to.

Any help on troubleshooting the issue would be appreciated, if more information is required, let me know!

Kind regards,
Thijs

1 Like

Hi @ThijsRoodbeen,

The ‘asApp()’ method relies on the app having all the required permissions. If it does, the request should work regardless of who uses the app.

I’d start by reviewing what scopes your app lists in the manifest.

Hope that helps! Let me know if you’re still running into problems.
Mel

@ThijsRoodbeen
As stated above it needs manifest permissions.
add read:space:confluence under scopes to your manifest.

Hi @mpaisley, @MartinKistnerDecadis,

Thanks for the additional information. I have rechecked the scopes for each endpoint used and rebuild the scopes from that:
permissions:
scopes:
- read:space:confluence
- read:confluence-content.summary
- read:confluence-space.summary
- read:space.permission:confluence
- search:confluence
- read:confluence-groups
- read:permission:confluence
- read:confluence-user
- read:content-details:confluence
- read:confluence-content.permission
- read:confluence-content.all
- read:content:confluence

(I tried including some grannular permissons too just to check)

The strange thing is that it works on some instances without issue, however, it does not seem to work for all instances I try on, for some it will just give me an empty result when requesting the spaces.
For example when trying to find a space ID using /wiki/api/v2/spaces?keys=
I also get an empty result when using asApp, asUser I recieve the correct result. Same with permission requests etc.

Any other checks I can perform?
Is my assumption correct the asApp can get all spaces regardless of user permissions?

Kind regards,
Thijs

Also having this issue. permissions are set correct, not 401 error, just an empty array returned.