Hi
It seems that this has been deprecated, See below for guidance.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Using .NET 4.8.1 and the code snippet below from Microsoft Learn (https://learn.microsoft.com/en-us/mem/intune/developer/data-warehouse-app-only-auth-). I am unable to get this module to work.
It seems the line with AuthenticationContext, ClientCredential and SecureClientSecret are outdated/depreciated. Example - error: ClientCredential' is obsolete: 'Use ConfidentialClientApplicationBuilder.WithCertificate or WithClientSecret instead. I cannot get this code snippet to work.
Can anyone help refine this?
Here's the complete class:
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");
}
private static SecureString ConvertToSecureStr(string appkey)
{
if (appkey == null)
throw new ArgumentNullException("AppKey must not be null.");
var secureAppKey = new SecureString();
foreach (char c in appkey)
secureAppKey.AppendChar(c);
secureAppKey.MakeReadOnly();
return secureAppKey;
}
}
Hi
It seems that this has been deprecated, See below for guidance.