如何解决'AuthenticationManager'不包含带有0个参数的构造函数
我有以下代码使用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
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);
};
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。