Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PnP Framework, Client Context Hangs

Tags:

c#

sharepoint

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;
    }
like image 383
Garen Avatar asked Apr 24 '26 19:04

Garen


1 Answers

This is t really an answer but I ended up going back to framework instead of core and used the old PnP.DEV and have had great success. No issues. So that is actually quite a bummer because I really wanted to italics core but oh well.

like image 54
Garen Avatar answered Apr 27 '26 08:04

Garen