WebDAV return 401 - How to authenticate?

给你一囗甜甜゛ 提交于 2019-12-23 05:23:17

问题


I have a problem with WebDAV. I have to get a list of files. I have this request:

<?xml version="1.0"?>
<D:searchrequest xmlns:D = "DAV:">
<D:sql>
    SELECT "DAV:displayname" FROM "address" WHERE "DAV:ishidden" = false AND "DAV:isfolder" = false 
</D:sql>
</D:searchrequest>

Response:

401 - Unauthorized: Access is denied due to invalid credentials.

I have user and password (who has access), but I don't know, how I can put this data to XML request.


回答1:


WebDAV uses an HTTP authentication.

So you put your credentials to an HTTP header, not to the WebDAV XML in the HTTP body.

The basic HTTP authentication works like:

  • You get a WWW-Authenticate header from the server

    WWW-Authenticate: Basic realm="server"
    
  • You include the Authorization header to the next request. The value of the header is:

    Authorization: Basic username:password
    

    where the username:password is in Base-64 encoding.

    Authorization: Basic dXNlcjpwYXNzd29yZA==
    

For details, see

  • Basic access authentication on Wikipedia
  • RFC 7235: Hypertext Transfer Protocol (HTTP/1.1): Authentication


来源:https://stackoverflow.com/questions/32393846/webdav-return-401-how-to-authenticate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!