SharePoint 以编程方式访问错误:AADSTS65001 DelegationDoesNotExist 用户或管理员尚未同意使用 ID X 的应用程序

问题描述 投票:0回答:1

我正在使用 office365-rest-python-client 以编程方式访问 Office365 在线中的 SharePoint 网站。

我要加入的应用程序只是一个将在后端运行的 Python 脚本 为此,我访问了 https://entra.microsoft.com/ 管理中心并执行了以下操作:

  • 1- 在“应用程序”>“应用程序注册”中创建应用程序
  • 2-添加了一个秘密 到该应用程序
  • 3- 授予该应用程序许可 访问 SharePoint API
  • 4- 已获得管理员同意

然后使用office365-rest-python-client,我使用应用程序clientId和SecretValue发送请求以添加页面

请求失败,并在 Microsoft Office365 Entra 的审核日志中显示以下错误:

Based on the information you provided we have identified following issue and recommend taking the action to resolve the issue.
Error Code: 65001
Message: The user or administrator has not consented to use the application with ID ''(). Send an interactive authorization request for this user and resource.

在 Microsoft 文档中更深入地了解此错误,它指出

AADSTS65001 DelegationDoesNotExist - The user or administrator has not consented to use the application with ID X. Send an interactive authorization request for this user and resource.

客户端显示

POST /sites/security/_api/contextInfo

POST /sites/security/_api/sitePages/pages

回归

401  client error  “Unauthorized for url : https://my-sharepoint/sites/security/_api/sitePages/pages

这个问题的原因可能是什么??

提前致谢

python sharepoint office365
1个回答
0
投票

我使用了证书身份验证,它按照指定的方式工作https://pypi.org/project/Office365-REST-Python-Client/

  1. 使用 Azure AD 应用程序(证书凭据流程)

文档:

[Granting access via Azure AD App-Only][1]
[wiki][1]

示例:connect_with_client_certificate.py

© www.soinside.com 2019 - 2024. All rights reserved.