【发布时间】:2020-12-20 21:45:38
【问题描述】:
我正在尝试从 Python 访问 Sharepoint 站点,但 AADSTS 似乎有一个条件访问策略阻止我获取令牌。
有没有人使用 Office365 Python Rest Client 成功连接到 Sharepoint Rest Endpoint?
这是我看到的实际错误
"C:\Python\envs\dev\python.exe c:\Users\xxxxxx.vscode\extensions\ms-python.python-2020.8.105369\pythonFiles\lib\python\debugpy\launcher 52801 -- c:\xxxx\Code\PythonSharepointUpdate\readsharepoint.py " An error occurred while retrieving token from XML response: AADSTS53003: Access has been blocked by Conditional Access policies. The access policy does not allow token issuance. An error occurred while retrieving auth cookies from https://microsoft.sharepoint.com/_vti_bin/idcrl.svc/
I am trying to execute this code from the Sample
from office365.runtime.auth.user_credential import UserCredential
from office365.sharepoint.client_context import ClientContext
from office365.runtime.auth.authentication_context import AuthenticationContext
site_url = 'https://microsoft.sharepoint.com/teams/'
ctx = ClientContext(site_url).with_credentials(UserCredential("user@domain.com", "My Complex Password”))
web = ctx.web
ctx.load(web)
ctx.execute_query()
print("Web title: {0}".format(web.properties['Title']))
另外 – 有没有更好的方法来验证 Sharepoint – 我讨厌必须在代码中以明文形式输入我的密码☹
有人使用 ClientCredential 吗? Sharepoint 站点上是否有单独的设置来启用 ClientCredential?我们的 Sharepoint 是否允许我们这样做?
【问题讨论】:
标签: python rest sharepoint office365