I have been working on this for hours now and can't figure out even how to diagnose this issue. When I run this code and step through it, I get an AuthenticationManager class initated but when it goes to create the client context, It just hangs. No error, No break, No exception. Sits there and idles forever.
Thanks for the help, this has been driving me crazy for way to long.
Here is my code (Personal Information has been changed obviously)
public static class SharepointAPI
{
private static ClientContext cc { get; set; }
private static void GenVar()
{
if(cc == null)
{
string appId = "a9f346f5-7229-4127-bfa2-7605c4593ca6";
var scopes = new string[] { "https://contoso.sharepoint.com/.default" };
string siteURL = "https://contoso.sharepoint.com/sites/HR/";
string tenant = "contoso.onmicrosoft.com";
string certpath = Directory.GetCurrentDirectory() + "\\cert.pfx";
string certpass = @"Password123";
var certificate509 = GetCertificate(certpath, certpass);
cc = new PnP.Framework.AuthenticationManager(clientId: appId, certificate: certificate509, tenantId: tenant)
.GetContext(siteURL);
}
else
{
return;
}
}
private static X509Certificate2 GetCertificate(string filename, string pwd)
{
var certificate = new X509Certificate2(filename, pwd);
return certificate;
}