thegrizzlylabs / sardine-android

A WebDAV library for Android
Apache License 2.0
355 stars 70 forks source link

Connection issue #21

Closed solokhind closed 5 years ago

solokhind commented 5 years ago

I'm trying to connect to my webdav server with bigcommerce.com using your sardine-android library. I keep getting an error: "Error contacting https://partslinkent.com/dav/content/IMAG5774.jpg (401 )".

I have double checked the username and the password and confirmed that it is correct by using other clients to connect. The server is using HTTPS/SSL. Any help would be appreciated!!

Stacktrace: W/System.err: com.thegrizzlylabs.sardineandroid.impl.SardineException: Error contacting https://partslinkent.com/dav/content/IMAG5774.jpg (401 ) at com.thegrizzlylabs.sardineandroid.impl.handler.ValidatingResponseHandler.validateResponse(ValidatingResponseHandler.java:23) W/System.err: at com.thegrizzlylabs.sardineandroid.impl.handler.InputStreamResponseHandler.handleResponse(InputStreamResponseHandler.java:16) at com.thegrizzlylabs.sardineandroid.impl.handler.InputStreamResponseHandler.handleResponse(InputStreamResponseHandler.java:12) at com.thegrizzlylabs.sardineandroid.impl.OkHttpSardine.execute(OkHttpSardine.java:595) at com.thegrizzlylabs.sardineandroid.impl.OkHttpSardine.get(OkHttpSardine.java:284) at com.thegrizzlylabs.sardineandroid.impl.OkHttpSardine.get(OkHttpSardine.java:274) at com.thegrizzlylabs.sardineandroid.impl.OkHttpSardine.get(OkHttpSardine.java:269) at com.hollmanmedia.partslinkcamera.util.WebDavHelper$WebDavRequestTask.doInBackground(WebDavHelper.java:24) at com.hollmanmedia.partslinkcamera.util.WebDavHelper$WebDavRequestTask.doInBackground(WebDavHelper.java:16) at android.os.AsyncTask$2.call(AsyncTask.java:333) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) at java.lang.Thread.run(Thread.java:764)

Code:

`class WebDavRequestTask extends AsyncTask < String, Void, List < DavResource >> {

@Override protected List < DavResource > doInBackground(String...strings) { Sardine sardine = new OkHttpSardine(); sardine.setCredentials("the username", "the password", true);

try { InputStream stream = sardine.get("https://partslinkent.com/dav/content/IMAG5774.jpg";); } catch (Exception e) { e.printStackTrace(); }

return null; } }`

solokhind commented 5 years ago

Aah, should have looked through the closed issues first. Still new to this. Looks like my server is using Digest authentication. Using https://github.com/rburgst/okhttp-digest fixed the issue. Thanks!