Call admin api from forge app

Hi , Is it possible to call the following endpoint using the forge (confluence) app?
“/admin/v1/orgs/{orgId}/users/”
Thank you

Hi @JayPerera

Sorry, this is not currently possible - Forge doesn’t yet have a way for administrators to authorise apps to call org-level APIs because apps are installed within single sites.

This is something we would definitely like to improve in the future, but not sure when that might be at the moment.

Jira and Confluence both expose their own user and group management APIs, which could work for you, depending upon your use case.

Thank you for quick reply, will it be possible with connect app?

I tried to execute the same endpoint in the following way inside the forge app and it successfully executed with a hardcoded API key. Are there any concerns associated with using this execution approach?
(we are planning to request the user to input the API key within our settings)

const fetchAllUsersFromAdminAPI = async () => {

  const response = await fetch(
    "https://api.atlassian.com/admin/v1/orgs/{orgId}/users/",
    {
      method: "GET",
      headers: {
        Authorization: "Bearer {api key}",

      },
    }
  );
  const data = await response.json();
};

I don’t think it will work with a Connect app either.

Yes, you can use an API token to call this API if there is no other way to do it. However, please be aware of Atlassian’s policy regarding apps that require users to persist API tokens with the app: https://developer.atlassian.com/platform/marketplace/security-requirements/#all-cloud-apps (See Point 10. - Privacy).

1 Like

Thank you