'AuthenticationManager' 不包含采用 0 个参数的构造函数

'AuthenticationManager' does not contain a constructor that takes 0 arguments

我有以下代码使用 clientID 和 ClientSecret 连接到 SharePoint:-

string siteUrl = "https://****l.sharepoint.com/sites/DocumentApprovalProcess/";
string clientId = "***";
string clientSecret = "**";

using (var context = new AuthenticationManager().GetAppOnlyAuthenticatedContext(siteUrl, clientId, clientSecret))

但是我收到这个错误:-

'AuthenticationManager' does not contain a constructor that takes 0 arguments   

请确保您安装了 Office Dev PnP:https://www.nuget.org/packages/SharePointPnPCoreOnline

你可以参考这篇文章:https://www.c-sharpcorner.com/article/connect-to-sharepoint-online-site-with-app-only-authentication/

using OfficeDevPnP.Core;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Client;

    string siteUrl = "https://tenant.sharepoint.com/sites/demo";  
    using (var cc = new AuthenticationManager().GetAppOnlyAuthenticatedContext(siteUrl, "[Your Client ID]", "[Your Client Secret]"))  
    {  
        cc.Load(cc.Web, p => p.Title);  
        cc.ExecuteQuery();  
        Console.WriteLine(cc.Web.Title);  
    };