Мы переходим на проверку подлинности сертификата клиента в нашем приложении и в настоящее время работаем над получением количества удаленных объектов приложения из API Microsoft Graph, следуя https://learn.microsoft.com/en-us/graph/sdks/choose. -authentication-providers#client-credentials-provider. Вот код, который мы уже разработали:
Код: Выделить всё
var scopes = new[] { "https://graph.microsoft.com/.default" };
var clientId = "YOUR_CLIENT_ID";
var tenantId = "YOUR_TENANT_ID";
var clientCertificate = new X509Certificate2("MyCertificate.pfx");
var options = new ClientCertificateCredentialOptions
{
AuthorityHost = AzureAuthorityHosts.AzurePublicCloud,
};
var clientCertCredential = new ClientCertificateCredential(
tenantId, clientId, clientCertificate, options);
var graphClient = new GraphServiceClient(clientCertCredential, scopes);
try
{
var result = await graphClient.Directory.DeletedItems.GraphApplication.GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Count = true;
requestConfiguration.QueryParameters.Orderby = new string[] { "deletedDateTime asc" };
requestConfiguration.QueryParameters.Select = new string[] { "id", "displayName", "deletedDateTime" };
requestConfiguration.Headers.Add("Consistencylevel", "Eventual");
});
}
catch (Exception ex)
{
Console.WriteLine($"An error occurred: {ex.Message}");
}
Internal.Cryptography.CryptoThrowHelper.WindowsCryptographicException: 'The specified network password is not correct.'
We've ensured that the calling application has been granted the required permissions, including Directory.Read.All and Application.Read.All.
Could you please assist in identifying the issue and providing guidance on how to resolve it? Any help would be greatly appreciated.
Источник: https://stackoverflow.com/questions/781 ... n-the-spec