c# - “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);
};
推荐阅读
- android - 发生异常时测试 Android 应用行为
- go - 如何将已经存在的 golang 项目从 go 路径迁移到 go 模块
- angular - 意外的指令“MatCard”导入了 Angular Material 8 错误——
- android - Android Webview contentHeight 具有上次访问页面的值
- javascript - 为什么我在我的 React 应用程序中丢失了登录信息?
- node.js - 在我的测试用例中,我的 console.log 没有输出
- amazon-web-services - Flink - AWS 上的外部检查点
- r - 在 ggplot 中突出显示我的一个折线图
- sql - SQL 正则表达式 substr 模式匹配
- python - 将“in”成员资格分配给变量?