'Why an installed app is not listed by Ms Graph API?

I am trying to upgrade an app which belongs to a chat. If the app is not installed, below code successfully install it:

await graph.Chats["19:[email protected]"].InstalledApps
                .Request()
                .AddAsync(teamsAppInstallation);

But once the app is added, below code shows zero entries:

var installedApps = await graph.Chats["19:[email protected]"].InstalledApps.Request().GetAsync();

I was expecting to see my app there. My target is to call Upgrade() for the app, because it should allow me to add ConversationReferences in one of the event functions (e.g. OnTurnAsync), that will allow me to send proactive message to the chat. Am I doing something wrong? Permissions for an application are set:

TeamsAppInstallation.ReadWriteSelfForChat.All
TeamsAppInstallation.ReadWriteForUser.All

The authentication with the Graph API is done successfully, as I can create a chat, list channels etc.

https://login.microsoftonline.com/botframework.com/oauth2/v2.0/token data: grant_type=client_credentials&client_id={ MS_APP_ID_ENC }&client_secret={ MS_APP_PASS_ENC }&scope=https%3A%2F%2Fgraph.microsoft.com%2F.default

I was adding the app to the chat both manually and with C# request:

var teamsAppInstallation = new TeamsAppInstallation {
AdditionalData = new Dictionary<string, object>()
{
    {
        "[email protected]", "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/0c...68/"}
    }
};
var installedApp = await graph.Chats["19:[email protected]"].InstalledApps.  Request().AddAsync(teamsAppInstallation);

And the app was added. It can be used in the chat.



Solution 1:[1]

It turned out that I've used wrong application permissions. Even though TeamsAppInstallation.ReadWriteSelfForChat.Al is listed in the docs, I needed to add TeamsAppInstallation.ReadWriteForChat.All to make it working.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Morales1235