Office365-rest-python-client: AttributeError: 'ClientContext' 对象没有属性 '_auth_context'

创建于 2020-12-08  ·  10评论  ·  资料来源: vgrem/Office365-REST-Python-Client

@vgrem

当我尝试运行以下代码片段时,我仍然收到错误“AttributeError: 'ClientContext' object has no attribute '_auth_context'”。 请帮忙解决

pip 安装 Office365-REST-Python-Client
ctx_auth = AuthenticationContext(Sharepoint_SiteUrl)
ctx_auth.acquire_token_for_user(用户,Sharepoint_Password)
ctx = ClientContext(Sharepoint_SiteUrl, ctx_auth)
网络 = ctx.web
ctx.load(web)
ctx.execute_query()
print("认证成功")

所有10条评论

嘿!

如何从AuthenticationContext.acquire_token_for_user切换:

ctx_auth = AuthenticationContext(Sharepoint_SiteUrl)
ctx_auth.acquire_token_for_user(User, Pass)
ctx = ClientContext(Sharepoint_SiteUrl, ctx_auth) 

ClientContext.with_user_credentials方法:

ctx = ClientContext(site_url).with_user_credentials(username,password)

还是没有运气?

但是我需要使用令牌而不是直接在请求中使用凭据..那么上面的代码还会使用tiken吗?

关于原始错误

“AttributeError: 'ClientContext' object has no attribute '_auth_context'” 当我尝试运行以下代码片段时。 请帮忙解决

确实存在在传递到ClientContext时保留AuthenticationContext实例的错误

_fixed_ 版本可以从 GitHub 下载:

pip install git+https://github.com/vgrem/Office365-REST-Python-Client.git

关于

但是我需要使用令牌而不是直接在请求中使用凭据..那么上面的代码还会使用tiken吗?

当然,在幕后, ClientContext.with_user_credentialsAuthenticationContext.acquire_token_for_user在构造经过身份验证的请求方面是相同的

嗨@vgrem
我在 databricks 中使用此代码,我们需要在集群级别安装库..那里我们没有从 git 下载的选项......
这个新变化什么时候作为库的一部分可用?

到目前为止还没有特定的发布日期,但很可能在本周末之前。

@vgrem
如果在这个周末之前发布它会很有帮助..下周是我们对此代码的主要测试..
同时,我将尝试您提到的其他代码片段。

我还有一个问题。 对于客户端凭据,应该在 sharepoint 在线站点中注册具有客户端 id 的 qpp 还是应在 azure 活动目录中注册应用程序?

支持这两个选项(SharePoint ACS 和 Azure AD)。

@vgrem
谢谢澄清

此页面是否有帮助?
0 / 5 - 0 等级