I'm running into some trouble when trying to get a client context from PnP for an Azure AD app only connection.
I'm trying to follow This tutorial on how to create an application that would run on a SharePoint tenant with DisableCustomAppAuthentication
on.
Unfortunately I fall short when it comes to retrieving the client context from Azure in c#. Exactly at this point:
public class CustomAuth
{
public static ClientContext GetContextObject(string siteUrl)
{
string _clientId = ConfigurationManager.AppSettings["ClientId"];
string _clientSecret = ConfigurationManager.AppSettings["ClientSecret"];
var authManager = new AuthenticationManager("********-b7a4-4d80-8254-920df9b5df4e", "c:\\dev\\cert.pfx", "******", "mytenant.sharepoint.com");
var context = authManager.GetAzureADAppOnlyAuthenticatedContext(siteUrl);
context.Load(context.Web, p => p.Title);
try
{
context.ExecuteQuery();
}
catch (Exception e)
{
Console.WriteLine(e);
}
return context;
}
}
It seems that the authentication manager does not contain the GetAzureAd function. I tried with GetContext instead, but it just loads indefinitely.
I'm on .net 4.7.2 , the NuGet for PNP.Framework is on 1.10 and PnPCore is on 1.7.90. Do I need to upgrade .net for it to work ?