【问题标题】:Microsoft SharePoint API access deniedMicrosoft SharePoint API 访问被拒绝
【发布时间】:2020-03-09 23:50:39
【问题描述】:

我正在尝试在 python 中使用 REST GET 调用来获取 RoleDefinitionBindings

问题是在某些呼叫中我得到了正确的响应,即

https://my_company.sharepoint.com/_api/Web/RoleAssignments(25)/RoleDefinitionBindings

但另一方面,我得到“拒绝访问”。即在

https://my_company.sharepoint.com/sites/Company/_api/Web/RoleAssignments(4)/RoleDefinitionBindings

我明白了

AccessDeniedError("403: https://my_company.sharepoint.com/sites/Company/_api/Web/RoleAssignments(4)/RoleDefinitionBindings: {'odata.error': {'code': '-2147024891, System.UnauthorizedAccessException', '消息':{'lang':'en-US', '值':'访问被拒绝。您无权执行此操作或访问此资源。'}}}")

我不知道是什么问题, 我在 Active Directory 中为我的应用程序使用所有可能的 ShapePoint 范围:

    "https://my_company.sharepoint.com/AllSites.FullControl",
    "https://my_company.sharepoint.com/AllSites.Read",
    "https://my_company.sharepoint.com/User.Read.All",
    "https://my_company.sharepoint.com/AllSites.Manage",
    "https://my_company.sharepoint.com/AllSites.Write",
    "https://my_company.sharepoint.com/MyFiles.Read",
    "https://my_company.sharepoint.com/MyFiles.Write",
    "https://my_company.sharepoint.com/Sites.Search.All",
    "https://my_company.sharepoint.com/TermStore.Read.All",
    "https://my_company.sharepoint.com/TermStore.ReadWrite.All",
    "https://my_company.sharepoint.com/User.ReadWrite.All"

【问题讨论】:

  • 您的应用帐户是否已在您尝试访问的共享点站点上添加了任何权限集?
  • @DeividKamui 是的 - 我已经为我的应用授予了上述所有权限
  • 我的意思是在 SharePoint 网站中,您需要将活动目录帐户添加到适当的权限组,即:网站所有者、网站成员
  • 我不知道我也需要这样做。谢谢!顺便说一句,你知道怎么做吗?
  • 您需要让您的 SharePoint 管理员将该帐户添加到任何可用的权限组中(如果您计划访问任何其他其他操作(如创建库或列表),则完全控制会很好)。如果您是管理员,请转到站点设置,然后转到站点权限并添加您的帐户。如果您仍然遇到问题,还有其他选项可以访问 SharePoint REST API,但您需要编写更多代码。

标签: sharepoint sharepoint-api


【解决方案1】:

问题是我不是 SharePoint 网站上的管理员(尽管我是 Azure AD 上的管理员)。 将自己作为管理员添加到 SharePoint 后,问题就解决了

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-28
    • 1970-01-01
    • 1970-01-01
    • 2014-09-19
    • 1970-01-01
    • 2021-09-21
    相关资源
    最近更新 更多