通过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'

有人能给我指正确的方向吗?

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

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

最新更新