CSOM 和 Azure Web 应用程序身份验证失败

问题描述

我创建了一个 Azure Web App Net Framework 4.7 以通过 CSOM 连接到 SharePoint Online。当我使用我的管理员用户帐户时,它工作正常,但是如果我使用任何其他帐户(例如进程用户帐户或我的测试帐户),连接将失败。这两个帐户也是 SharePoint 网站的所有者,我可以使用这些帐户登录该网站。

此外,我注意到我 2 年前创建的其他一些 Azure Web 应用程序和 CSOM 项目不再有效。它们显示相同的错误消息。

为了测试这个连接,我使用以下代码创建了一个简单的 Azure Web 应用程序:

string siteUrl = "https://xxx.sharepoint.com/sites/yyy";
string userName "username";
string password = "password";
System.Security.securestring securestring = new System.Security.securestring();
      foreach (char ch in password.tochararray())
        securestring.AppendChar(ch);
SharePointOnlineCredentials creds = new SharePointOnlineCredentials(userName,securestring);

using (var clientContext = new ClientContext(siteUrl))
{
clientContext.Credentials = creds;
clientContext.Load(clientContext.Web,p => p.Title);
clientContext.ExecuteQuery();
Console.WriteLine(clientContext.Web.Title);

我在 clientContext.ExecuteQuery() 行收到一条错误消息:

System.Net.WebException: 'The Remote Server returned an error: (415).'

我用 Net Core 和 CSOM 创建了另一个项目,但我遇到了同样的错误。它仅适用于我的管理员用户帐户。

我需要更新 Azure 或 Web 配置中的新设置吗?我找不到有关此问题的任何资源以及与 CSOM 相关的 415 错误代码

如果有人可以提供帮助并提供适当的链接代码,我们将不胜感激。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)