Создать консоль токенов для хранилища данных IntuneC#

Место общения программистов C#
Гость
Создать консоль токенов для хранилища данных Intune

Сообщение Гость »


Here's the code snippet pulled from Microsoft Learn (https://learn.microsoft.com/en-us/mem/i ... only-auth-)
It seems the line with AuthenticationContext, ClientCredential and SecureClientSecret are depreciated. For example: ClientCredential' is obsolete: 'Use ConfidentialClientApplicationBuilder.WithCertificate or WithClientSecret instead. I cannot get this code snippet to work.

Код: Выделить всё

using System.Security;
using System.Configuration;
using Microsoft.Identity.Client;

class IntuneDataWarehouse
{
public static void Main()
{
Console.WriteLine("Intune Datawarehouse Start");

var applicationId = ConfigurationManager.AppSettings["appId"].ToString();
SecureString applicationSecret = ConvertToSecureStr(ConfigurationManager.AppSettings["appKey"].ToString()); // Load as SecureString from configuration file or secret store (i.e. Azure KeyVault)
var tenantDomain = ConfigurationManager.AppSettings["tenantDomain"].ToString();
var msalContext = new AuthenticationContext($"https://login.windows.net/" + tenantDomain + "/oauth2/token");

AuthenticationResult authResult = msalContext.AcquireTokenAsync(
resource: "https://api.manage.microsoft.com/",
clientCredential: new ClientCredential(
applicationId,
new SecureClientSecret(applicationSecret))).Result;

Console.WriteLine("End of run");
}
Has anyone worked on similar code?


Источник: https://stackoverflow.com/questions/781 ... awarehouse

Вернуться в «C#»