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 Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,051 questions
Microsoft Teams Development
Microsoft Teams Development
Microsoft Teams: A Microsoft customizable chat-based workspace.Development: The process of researching, productizing, and refining new or existing technologies.
2,963 questions
{count} votes

Accepted answer
  1. 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;
    
    0 comments No comments

0 additional answers

Sort by: Most helpful