Wählen Sie die Berechtigungen aus, die für diese API als am wenigsten privilegiert markiert sind. Verwenden Sie eine höhere Berechtigung oder Berechtigungen nur, wenn Ihre App dies erfordert. Ausführliche Informationen zu delegierten Berechtigungen und Anwendungsberechtigungen finden Sie unter Berechtigungstypen. Weitere Informationen zu diesen Berechtigungen finden Sie in der Berechtigungsreferenz.
Diese Berechtigungen TeamsAppInstallation.ReadWriteSelfForChat, TeamsAppInstallation.ReadWriteForChat, TeamsAppInstallation.ReadWriteSelfForChat.All und TeamsAppInstallation.ReadWriteForChat.All können nicht zum Installieren von Apps verwendet werden, die die Zustimmung zu ressourcenspezifischen Berechtigungen erfordern.
Der Anforderungstext sollte die generierte App-ID der Katalog-App enthalten. Weitere Informationen finden Sie unter teamsApp-Eigenschaften.
In der folgenden Tabelle sind weitere Parameter aufgeführt, die mit dem Anforderungstext verwendet werden können.
Satz von ressourcenspezifischen Berechtigungen, denen zugestimmt wird.
Anmerkung: Die während der Installation genehmigten Berechtigungen müssen mit den ressourcenspezifischen Berechtigungen übereinstimmen, die in teamsAppDefinition der App definiert sind. Informationen zum Abrufen der Anwendung und delegierter ressourcenspezifischer Berechtigungen finden Sie unter Beispiel 6. Wenn in teamsAppDefinition nur delegierte ressourcenspezifische Berechtigungen angegeben sind, können Berechtigungen im Anforderungstext weggelassen werden.
Antwort
Wenn die Methode erfolgreich verläuft, wird der Antwortcode 201 Created zurückgegeben.
POST https://graph.microsoft.com/v1.0/chats/19:ea28e88c00e94c7786b065394a61f296@thread.v2/installedApps
Content-Type: application/json
{
"teamsApp@odata.bind":"https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/12345678-9abc-def0-123456789a"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new TeamsAppInstallation
{
AdditionalData = new Dictionary<string, object>
{
{
"teamsApp@odata.bind" , "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/12345678-9abc-def0-123456789a"
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Chats["{chat-id}"].InstalledApps.PostAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewTeamsAppInstallation()
additionalData := map[string]interface{}{
"teamsApp@odata.bind" : "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/12345678-9abc-def0-123456789a",
}
requestBody.SetAdditionalData(additionalData)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
installedApps, err := graphClient.Chats().ByChatId("chat-id").InstalledApps().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
TeamsAppInstallation teamsAppInstallation = new TeamsAppInstallation();
HashMap<String, Object> additionalData = new HashMap<String, Object>();
additionalData.put("teamsApp@odata.bind", "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/12345678-9abc-def0-123456789a");
teamsAppInstallation.setAdditionalData(additionalData);
TeamsAppInstallation result = graphClient.chats().byChatId("{chat-id}").installedApps().post(teamsAppInstallation);
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.teams_app_installation import TeamsAppInstallation
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = TeamsAppInstallation(
additional_data = {
"teams_app@odata_bind" : "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/12345678-9abc-def0-123456789a",
}
)
result = await graph_client.chats.by_chat_id('chat-id').installed_apps.post(request_body)
Beispiel 2: Installieren der App in einem Chat und Zustimmung zu den ressourcenspezifischen Berechtigungen, die für die App erforderlich sind
Um die Liste der ressourcenspezifischen Berechtigungen abzurufen, die für die App erforderlich sind, rufen Sie die App aus appCatalog ab, wie in Beispiel 6 gezeigt.
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new TeamsAppInstallation
{
ConsentedPermissionSet = new TeamsAppPermissionSet
{
ResourceSpecificPermissions = new List<TeamsAppResourceSpecificPermission>
{
new TeamsAppResourceSpecificPermission
{
PermissionValue = "OnlineMeeting.ReadBasic.Chat",
PermissionType = TeamsAppResourceSpecificPermissionType.Delegated,
},
new TeamsAppResourceSpecificPermission
{
PermissionValue = "OnlineMeetingIncomingAudio.Detect.Chat",
PermissionType = TeamsAppResourceSpecificPermissionType.Delegated,
},
new TeamsAppResourceSpecificPermission
{
PermissionValue = "ChatMember.Read.Chat",
PermissionType = TeamsAppResourceSpecificPermissionType.Application,
},
new TeamsAppResourceSpecificPermission
{
PermissionValue = "ChatMessage.Read.Chat",
PermissionType = TeamsAppResourceSpecificPermissionType.Application,
},
},
},
AdditionalData = new Dictionary<string, object>
{
{
"teamsApp@odata.bind" , "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/2b524e28-95ce-4c9b-9773-4a5bd6ec1770"
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Chats["{chat-id}"].InstalledApps.PostAsync(requestBody);
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
TeamsAppInstallation teamsAppInstallation = new TeamsAppInstallation();
TeamsAppPermissionSet consentedPermissionSet = new TeamsAppPermissionSet();
LinkedList<TeamsAppResourceSpecificPermission> resourceSpecificPermissions = new LinkedList<TeamsAppResourceSpecificPermission>();
TeamsAppResourceSpecificPermission teamsAppResourceSpecificPermission = new TeamsAppResourceSpecificPermission();
teamsAppResourceSpecificPermission.setPermissionValue("OnlineMeeting.ReadBasic.Chat");
teamsAppResourceSpecificPermission.setPermissionType(TeamsAppResourceSpecificPermissionType.Delegated);
resourceSpecificPermissions.add(teamsAppResourceSpecificPermission);
TeamsAppResourceSpecificPermission teamsAppResourceSpecificPermission1 = new TeamsAppResourceSpecificPermission();
teamsAppResourceSpecificPermission1.setPermissionValue("OnlineMeetingIncomingAudio.Detect.Chat");
teamsAppResourceSpecificPermission1.setPermissionType(TeamsAppResourceSpecificPermissionType.Delegated);
resourceSpecificPermissions.add(teamsAppResourceSpecificPermission1);
TeamsAppResourceSpecificPermission teamsAppResourceSpecificPermission2 = new TeamsAppResourceSpecificPermission();
teamsAppResourceSpecificPermission2.setPermissionValue("ChatMember.Read.Chat");
teamsAppResourceSpecificPermission2.setPermissionType(TeamsAppResourceSpecificPermissionType.Application);
resourceSpecificPermissions.add(teamsAppResourceSpecificPermission2);
TeamsAppResourceSpecificPermission teamsAppResourceSpecificPermission3 = new TeamsAppResourceSpecificPermission();
teamsAppResourceSpecificPermission3.setPermissionValue("ChatMessage.Read.Chat");
teamsAppResourceSpecificPermission3.setPermissionType(TeamsAppResourceSpecificPermissionType.Application);
resourceSpecificPermissions.add(teamsAppResourceSpecificPermission3);
consentedPermissionSet.setResourceSpecificPermissions(resourceSpecificPermissions);
teamsAppInstallation.setConsentedPermissionSet(consentedPermissionSet);
HashMap<String, Object> additionalData = new HashMap<String, Object>();
additionalData.put("teamsApp@odata.bind", "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/2b524e28-95ce-4c9b-9773-4a5bd6ec1770");
teamsAppInstallation.setAdditionalData(additionalData);
TeamsAppInstallation result = graphClient.chats().byChatId("{chat-id}").installedApps().post(teamsAppInstallation);