首页 > 解决方案 > 通过 Python 使用单点登录访问 Office365 SharePoint

问题描述

我对 SharePoint 知之甚少,但我的任务是使用 Python 下载 SharePoint 列表。SharePoint 是 Office365,可通过单点登录进行访问。我找到了以下有关如何连接到 SharePoint 的示例:

from office365.runtime.auth.user_credential import UserCredential
from office365.sharepoint.client_context import ClientContext
ctx = ClientContext('https://<site>.sharepoint.com').with_credentials(UserCredential('domain\\user', 'password'))
web = ctx.web
ctx.load(web)
ctx.execute_query()
print(web.properties["Url"])

执行此代码时,我收到以下错误:

Cannot get binary security token for from https://login.microsoftonline.com/extSTS.srf
KeyError: 'FedAuth'

谁能指出我正确的方向?

标签: pythonsharepointoffice365single-sign-on

解决方案


最近在寻找类似的解决方案时,我发现了一些有用的东西,您可以在 github 上查看以下代码。

https://github.com/vgrem/Office365-REST-Python-Client


推荐阅读