Escolha a permissão ou permissões marcadas como menos privilegiadas para esta API. Utilize uma permissão ou permissões com privilégios mais elevados apenas se a sua aplicação o exigir. Para obter detalhes sobre as permissões delegadas e de aplicação, veja Tipos de permissão. Para saber mais sobre estas permissões, veja a referência de permissões.
Tipo de permissão
Permissões com menos privilégios
Permissões com privilégios superiores
Delegado (conta corporativa ou de estudante)
Synchronization.ReadWrite.All
Indisponível.
Delegado (conta pessoal da Microsoft)
Sem suporte.
Sem suporte.
Application
Application.ReadWrite.OwnedBy
Synchronization.ReadWrite.All
Importante
Em cenários delegados com contas escolares ou profissionais, o utilizador com sessão iniciada tem de ser proprietário ou membro do grupo ou ser-lhe atribuída uma função de Microsoft Entra suportada ou uma função personalizada com uma permissão de função suportada. As seguintes funções com menos privilégios são suportadas para esta operação.
Administrador de Aplicativos
Administrador de Aplicativos de Nuvem
Administrador de Identidade Híbrida – para configurar o Microsoft Entra Cloud Sync
Solicitação HTTP
POST /applications/{applicationsId}/synchronization/acquireAccessToken
POST /servicePrincipals/{servicePrincipalsId}/synchronization/acquireAccessToken
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Applications.Item.Synchronization.AcquireAccessToken;
using Microsoft.Graph.Models;
var requestBody = new AcquireAccessTokenPostRequestBody
{
Credentials = new List<SynchronizationSecretKeyStringValuePair>
{
new SynchronizationSecretKeyStringValuePair
{
OdataType = "microsoft.graph.synchronizationSecretKeyStringValuePair",
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Applications["{application-id}"].Synchronization.AcquireAccessToken.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"
graphapplications "github.com/microsoftgraph/msgraph-sdk-go/applications"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphapplications.NewAcquireAccessTokenPostRequestBody()
synchronizationSecretKeyStringValuePair := graphmodels.NewSynchronizationSecretKeyStringValuePair()
credentials := []graphmodels.SynchronizationSecretKeyStringValuePairable {
synchronizationSecretKeyStringValuePair,
}
requestBody.SetCredentials(credentials)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.Applications().ByApplicationId("application-id").Synchronization().AcquireAccessToken().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.applications.item.synchronization.acquireaccesstoken.AcquireAccessTokenPostRequestBody acquireAccessTokenPostRequestBody = new com.microsoft.graph.applications.item.synchronization.acquireaccesstoken.AcquireAccessTokenPostRequestBody();
LinkedList<SynchronizationSecretKeyStringValuePair> credentials = new LinkedList<SynchronizationSecretKeyStringValuePair>();
SynchronizationSecretKeyStringValuePair synchronizationSecretKeyStringValuePair = new SynchronizationSecretKeyStringValuePair();
synchronizationSecretKeyStringValuePair.setOdataType("microsoft.graph.synchronizationSecretKeyStringValuePair");
credentials.add(synchronizationSecretKeyStringValuePair);
acquireAccessTokenPostRequestBody.setCredentials(credentials);
graphClient.applications().byApplicationId("{application-id}").synchronization().acquireAccessToken().post(acquireAccessTokenPostRequestBody);
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Applications\Item\Synchronization\AcquireAccessToken\AcquireAccessTokenPostRequestBody;
use Microsoft\Graph\Generated\Models\SynchronizationSecretKeyStringValuePair;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new AcquireAccessTokenPostRequestBody();
$credentialsSynchronizationSecretKeyStringValuePair1 = new SynchronizationSecretKeyStringValuePair();
$credentialsSynchronizationSecretKeyStringValuePair1->setOdataType('microsoft.graph.synchronizationSecretKeyStringValuePair');
$credentialsArray []= $credentialsSynchronizationSecretKeyStringValuePair1;
$requestBody->setCredentials($credentialsArray);
$graphServiceClient->applications()->byApplicationId('application-id')->synchronization()->acquireAccessToken()->post($requestBody)->wait();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.applications.item.synchronization.acquire_access_token.acquire_access_token_post_request_body import AcquireAccessTokenPostRequestBody
from msgraph.generated.models.synchronization_secret_key_string_value_pair import SynchronizationSecretKeyStringValuePair
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = AcquireAccessTokenPostRequestBody(
credentials = [
SynchronizationSecretKeyStringValuePair(
odata_type = "microsoft.graph.synchronizationSecretKeyStringValuePair",
),
],
)
await graph_client.applications.by_application_id('application-id').synchronization.acquire_access_token.post(request_body)