skazantsev / WebDavClient

Asynchronous cross-platform WebDAV client for .NET Core
MIT License
156 stars 30 forks source link

digest authentication #32

Open ningma97 opened 5 years ago

ningma97 commented 5 years ago

Hi, I have a WebDAV server which uses the digest method for authentication.

This appears a problem for WebDavClient. Any advice on how to change WebDavClientParams to use digest credentials?

The error I got is:

{PROPFIND WebDAV response - StatusCode: 417, Description: Expectation Failed}

Many thanks Ning

skazantsev commented 5 years ago

Hi Ning,

I haven't used digest auth with WebDavClient but I hope this case is supported. Try passing CredentialCache as credentials. Under the hood these credentials are passed to HttpClientHandler.Credentials (https://github.com/skazantsev/WebDavClient/blob/master/src/WebDav.Client/WebDavClient.cs#L778:L782)

This SO topic can be helpful: https://stackoverflow.com/questions/10658202/httprequestmessage-and-digest-authentication

Let me know if it helps.

tipa commented 4 years ago

I encounter the same problem. Interestingly, it only is a problem on Xamarin.iOS, while it works fine in UWP. Xamarin.iOS apparently uses Basic Authentication by default and when trying to force Digest authentication with the CredentialCache directly as you suggested, it didn't work either (or at least, not reliably). Maybe this is a bug on Xamarin.iOS as no Authorization header is set when inspecting the packages in Fiddler.

Would you be able to implement this workaround into the library? https://stackoverflow.com/a/10179991/3585218