python - SecureAuth 原因 - ShareplumRequestError : Shareplum HTTP Post Failed : 403 Client Error: Forbidden for url

标签 python sharepoint office365 shareplum

我们正在尝试访问共享点,我们是否成功取决于特定共享点部分是否受“SecureAuth”保护。
如果 url 不受“SecureAuth”保护,程序可以正常工作,但如果此 URL 受“SecureAuth”保护,它会返回此错误。有什么办法可以解决吗?
我们正在使用:

 from shareplum import Site
 from shareplum import Office365
 from shareplum.site import Version

 authcookie = Office365(sharepoint_address, username=sharepoint_user,\
                        password=sharepoint_user_pw).GetCookies()
 site = Site(f"https://myWeb.com/sites/{sharepoint_site}/", version=Version.v365, authcookie=authcookie)
 folder = site.Folder(sharepoint_folder) # here come the error
取决于 {sharepoint_site} 它的工作与否。
它是相同的错误,但与 topic 无关

最佳答案

目前尚不清楚您需要访问的 SharePoint 是 OnPremises 还是 Online (Office 365),但我将分享所有可能性和各自的方法:
如果 SharePoint 站点地址包含 https://[tenant].sharepoint.com/sites/BusinessAreaOfCompany 格式,其中 【租户】是一个字符串,表示公司的引用。该站点托管在 Office 365 环境中;比,您共享的上面的代码示例(并且用户需要最少的权限),如下所示:

from shareplum import Site
from shareplum import Office365

authcookie = Office365('https://[tenant].sharepoint.com', username='username@[tenantdomain].com', password='password').GetCookies()
site = Site('https://[tenant].sharepoint.com/sites/BusinessAreaOfCompany', authcookie=authcookie)
否则,如果 SharePoint 站点 url 使用与租户地址不同的任何公司域,例如 https://xyz.company.com/sites/BusinessAreaOfCompany ,SharePoint 是一个本地环境,并使用 NTLM 或 Kerberos 进行身份验证。适当的代码方法示例是(记住:用户需要最少的权限):
from shareplum import Site
from requests_ntlm import HttpNtlmAuth

cred = HttpNtlmAuth('Username', 'Password')
site = Site('https://xyz.company.com/sites/BusinessAreaOfCompany', auth=cred)
引用:SharePlum: Python + SharePoint

关于python - SecureAuth 原因 - ShareplumRequestError : Shareplum HTTP Post Failed : 403 Client Error: Forbidden for url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68390250/

相关文章:

c# - Sharepoint 2013 中的联合身份验证 : getting rtFa and FedAuth cookies

android - 用于从另一个应用程序打开 Outlook Groups 应用程序的深度链接

angularjs - 如何将模型从 Word 2016 传递到 Office 365 Dialog?

python - 在不使用命令行参数的情况下从 python 程序启动 celery beat

python - 为什么 localhost :5000 not work in Flask Python?

html - float 菜单内容高度

sql-server - Sharepoint 365 和 SQL 访问

Python:追加原始对象与追加对象的副本

python正则表达式以跳过模式拆分某些模式

sharepoint - 如何缓存基于 Sharepoint 托管客户端对象模型的对象?