Getting error while connecting to Office 365 sharepoint

Viewed 37

I am trying to connect to office 365 sharepoint using clientid and clientsecret in OfficeDevPnP.Core.AuthenticationManager() method but i am getting below error

Connection Error

I am using below code to connect to sharepoint:

        var authManager = new OfficeDevPnP.Core.AuthenticationManager();
        string appId = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
        string appSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
        string siteURL = "https://xxxxxxxx.sharepoint.com/";
        string siteName = "";
        using (ClientContext context = authManager.GetAppOnlyAuthenticatedContext(siteURL, appId, appSecret))
        {
            Site objSite = context.Site;
            context.Load(objSite);
            context.ExecuteQuery();
            siteName = objSite.Url.ToString();
            Console.WriteLine("Site Url:" + objSite.Url);
        }

What am I doing wrong? Currently my site is localhost so have setup below details

App register details

1 Answers

Your company must have a Proxy, it will be necessary to define the following information in your Web Config:

<system.net>
   <defaultProxy enabled="true">
     <proxy proxyaddress="http://urlyourproxy:port" bypassonlocal="True"/>
   </defaultProxy>
</system.net>

Right after inserting this works fine!

Related