【发布时间】:2020-03-30 08:17:46
【问题描述】:
使用 pythons webdav.client 我连接到 Nextcloud。
import webdav.client as wc
def webdav_con(webdav_hostname, webdav_usr, webdav_password):
options = {
'webdav_hostname': webdav_hostname,
'webdav_login': webdav_usr,
'webdav_password': webdav_password,
'webdav_root': "/remote.php/webdav"
}
return client = wc.Client(options)
cloud_client = webdav_con(hostname_webdav_nextcloud, usr_nextcloud, pw_nextcloud)
然后我列出路径中的文件并在之后处理它们。
files_in_cloud = cloud_client.list("path_in_cloud")
到目前为止一切顺利 - 在我的本地机器上执行脚本时没有问题。当我尝试在我们的 gitlab 服务器上运行脚本时,问题就出现了。
webdav.exceptions.RemoteResourceNotFound: Remote resource: path_in_cloud not found
即使我只想列出根目录中的文件,我也会遇到错误。似乎我的身份验证有问题,这很奇怪,因为我使用与本地机器上相同的凭据/相同的 url 和 root。
webdav.exceptions.ResponseErrorCode: Request to my_cloud_url failed with code 401 and message: b'<?xml version="1.0" encoding="utf-8"?>\n<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">\n <s:exception>Sabre\\DAV\\Exception\\NotAuthenticated</s:exception>\n <s:message>No \'Authorization: Basic\' header found. Either the client didn\'t send one, or the server is misconfigured, No \'Authorization: Bearer\' header found. Either the client didn\'t send one, or the server is mis-configured</s:message>\n</d:error>\n'
非常感谢任何帮助!
【问题讨论】:
标签: python gitlab-ci webdav nextcloud