将Python连接到SharePoint

发布于 2025-02-09 14:08:39 字数 976 浏览 1 评论 0原文

希望通过python与代码下方的简单脚本连接到SharePoint

from office365.runtime.auth.user_credential import UserCredential

def get_sharepoint_context_using_user():
 
    # Get sharepoint credentials
    sharepoint_url = 'https://abc.sharepoint.com'

    # Initialize the client credentials
    user_credentials = UserCredential("[email protected]", "fakePass123")

    # create client context object
    ctx = ClientContext(sharepoint_url).with_credentials(user_credentials)

    return ctx

没有任何错误,但是当我调用 get_sharepoint_context_context_user_user()时,在我的脚本的另一部分中,我会收到以下错误,

NameError: name 'get_sharepoint_context_using_app' is not defined

我也有一个红色“ x”在线上 ctx = clientContext(sharepoint_url).with_credentials(user_credentials) client client上下文不确定。

有什么想法吗?

Looking to connect to SharePoint via python with the simple script below

from office365.runtime.auth.user_credential import UserCredential

def get_sharepoint_context_using_user():
 
    # Get sharepoint credentials
    sharepoint_url = 'https://abc.sharepoint.com'

    # Initialize the client credentials
    user_credentials = UserCredential("[email protected]", "fakePass123")

    # create client context object
    ctx = ClientContext(sharepoint_url).with_credentials(user_credentials)

    return ctx

The code runs without any errors but when I call the get_sharepoint_context_using_user() later on in another section of my script I receive the following error

NameError: name 'get_sharepoint_context_using_app' is not defined

There is also a red "x" on the line with
ctx = ClientContext(sharepoint_url).with_credentials(user_credentials) saying client context is undefined.

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文