Access denied for appCatalogs/teamsApps

Denis Sumin 96 Reputation points
2021-03-03T13:38:48.68+00:00

I'm calling https://graph.microsoft.com/v1.0/appCatalogs/teamsApps to find id of my app, but I'm getting AccessDenied error.

This looks like a Graph bug because my app has all the necessary permissions to access the Teams Apps list.

The application flow description:

  1. Ask for the Admin consent using https://login.microsoftonline.com/${tenantId}/adminconsent?client_id=${clientId}&redirect_uri=${redirectUrl}
  2. Obtain the access token from Graph API /api/getToken?tenantId=${tenantId}&secret=${secret}
  3. Use "@microsoft/microsoft-graph-client" to access /appCatalogs/teamsApps
  4. Receive { "error": { "code": "Forbidden", "message": "Forbidden" } }

App permissions:
AppCatalog.Read.All
Chat.Read.All
Directory.AccessAsUser.All
Directory.Read.All
Group.Read.All
TeamsAppInstallation.ReadWriteForUser.All
TeamsAppInstallation.ReadWriteSelfForUser.All
User.Read.All
TeamsApp.Read.All

Microsoft Teams | Development
Microsoft Teams | Development

Building, integrating, or customizing apps and workflows within Microsoft Teams using developer tools and APIs

Microsoft Security | Microsoft Graph

Answer accepted by question author
Denis Sumin 96 Reputation points
2021-03-23T10:00:09.003+00:00

MS Graph, for now, doesn't support this query from the autonomous application, and only the user can query this data.
My workaround is: get installed applications from the user who has already installed the app and read the id from the result.

const { Client } = require("@microsoft/microsoft-graph-client");
const client = Client.init({ ... });
const response = await client
  .api(`/users/${userId}/teamwork/installedApps`)
  .expand("teamsApp")
  .filter(`teamsApp/displayName eq '${appName}'`)
  .get();
const internalAppId = response?.value[0]?.teamsApp.id;

Was this answer helpful?

0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.