小编Sai*_*han的帖子

无法从 C# .Net Core 应用程序连接并获取 Sharepoint 数据

在.Net 6环境中使用pnp.Framework时。我需要经过身份验证的客户端上下文来获取 Sharepoint 数据,但在运行context.ExecuteQuery()时面临 403forbidden 。

我想使用 clientId 和 clientSecret 身份验证模式将数据从客户端获取到我的环境,但面临 403 禁止请求。

我在特定的 Azure Active Directory 中注册了应用程序并添加了以下权限。

在此输入图像描述

using PnP.Framework;
using System.Security;
using System.Web;

namespace SharePointOnlinePNPProject
{
    public class Program
    {
        static async Task Main(string[] args)
        {
            string appID= "appId/clientId";
            string tenantId = "<tenantId>";
            string clientSecret = "";
            string queueTestingLink = "Input sharepoint url";
            Uri site = new Uri("https://clientDomain.sharepoint.com");
            string filePath= "/Shared Documents/Case Studies"

            SecureString password = new SecureString();
            foreach (char c in passcode)
            {
                password.AppendChar(c); …
Run Code Online (Sandbox Code Playgroud)

.net sharepoint-online pnp-js microsoft365 .net-6.0

3
推荐指数
1
解决办法
5225
查看次数

标签 统计

.net ×1

.net-6.0 ×1

microsoft365 ×1

pnp-js ×1

sharepoint-online ×1