【发布时间】:2020-05-01 15:37:42
【问题描述】:
我已经构建了一个 Python 应用程序来生成库存 CSV 文件,并且我想通过 BigCommerce 的 WebDAV 应用程序将该文件上传到我的商店。我正在使用以下 Python 客户端访问 WebDAV。
https://pypi.org/project/webdavclient3/
我可以使用 CyberDuck 访问我的商店并将文件添加到内容文件夹,但是当我尝试从我的 Python 脚本访问它时收到 HTTP 401 错误。这是我用来连接 WebDAV 的。
# webDAV upload to BigCommerce
options = {
'webdav_hostname': "https://mystore.com",
'webdav_login': "email@email.com",
'webdav_password': "password",
'webdav_root': "/dav/",
}
client = Client(options)
print("Exist:", client.check("/content/mytest")) # returns "Exist: False"
print(client.list())
print(client.free())
print("HERE")
我在 client.list() 处收到一个错误
Request to https://mystore.com/dav/ failed with code 401 and message:
<?xml version="1.0" encoding="utf-8"?>
<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns"><s:exception>Sabre\\DAV\\Exception\\NotAuthenticated</s:exception><s:message>No 'Authorization: Digest' header found. Either the client didn't send one, or the server is misconfigured</s:message>
</d:error>
我猜这是说我的登录名和/或密码不正确或没有身份验证?但是我怎么可以使用相同的凭据通过 CyberDuck 登录呢?
我看到有人在以下链接中询问类似的问题,我已经尝试了 Karen 的建议。他们都没有工作。
【问题讨论】:
-
您在发出此请求时是否发送任何授权标头?我建议将通过 Cyberduck 发送的标头与通过 Python 客户端发送的标头进行比较,听起来至少有一个所需的标头没有被发送。
标签: python bigcommerce webdav