Elija el permiso o los permisos marcados como con privilegios mínimos para esta API. Use un permiso o permisos con privilegios superiores solo si la aplicación lo requiere. Para obtener más información sobre los permisos delegados y de aplicación, consulte Tipos de permisos. Para obtener más información sobre estos permisos, consulte la referencia de permisos.
Estos permisos TeamsAppInstallation.ReadWriteSelfForChat, TeamsAppInstallation.ReadWriteForChat, TeamsAppInstallation.ReadWriteSelfForChat.All y TeamsAppInstallation.ReadWriteForChat.All no se pueden usar para instalar aplicaciones que requieran consentimiento para permisos específicos de recursos.
El cuerpo de la solicitud debe incluir el identificador de aplicación generado de la aplicación de catálogo. Para obtener más información, consulte las propiedades de teamsApp.
En la tabla siguiente se enumeran otros parámetros que se pueden usar con el cuerpo de la solicitud.
Conjunto de permisos específicos de recursos a los que se está dando su consentimiento.
Nota: Los permisos consentidos durante la instalación deben coincidir con los permisos específicos del recurso definidos en teamsAppDefinition de la aplicación. Para obtener la aplicación y los permisos específicos de recursos delegados, consulte el ejemplo 6. Si solo se especifican permisos delegados específicos de recursos en teamsAppDefinition, los permisos se pueden omitir en el cuerpo de la solicitud.
Respuesta
Si se ejecuta correctamente, este método devuelve un código de respuesta 201 Created.
Ejemplos
Ejemplo 1: Instalación de la aplicación en un chat
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)
Ejemplo 2: Instalación de la aplicación en un chat y consentimiento para los permisos específicos del recurso requeridos por la aplicación
Para obtener la lista de permisos específicos de recursos requeridos por la aplicación, obtenga la aplicación desde appCatalog, como se muestra en el ejemplo 6.
// 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);