繁体   English   中英

使用 python office 365 将文件上传到 sharepoint

[英]upload file to sharepoint using python office 365

我正在尝试使用仅应用程序凭据将文件上传到 sharepoint,但在身份验证步骤失败。 不知道这里有什么问题,也验证了应用程序ID的权限,但仍然没有运气。

非常感谢任何输入!

错误信息

TypeError: init () got an unexpected keyword argument 'url'

from office365.runtime.auth.authentication_context import AuthenticationContext
from office365.sharepoint.client_context import ClientContext
from office365.sharepoint.files.file import File
site_url = 'https://contoso.sharepoint.com/'
 app_principal = {
     'client_id': '--client-id-goes-here--',
     'client_secret': '--client-secret-goes-here--',
 }
    
 context_auth = AuthenticationContext(url=site_url)
 context_auth.acquire_token_for_app(client_id=app_principal['client_id'], client_secret=app_principal['client_secret'])
    
 ctx = ClientContext(site_url, context_auth)
 web = ctx.web
 ctx.load(web)
 ctx.execute_query()
 print("Web site title: {0}".format(web.properties['Title']))

url 应如下所示

site_url = 'https://contoso.sharepoint.com/sites/xxx'

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM