how to implement digest authentication using volley?
Asked Answered
F

2

10

Any one can help me for implement digest authentication using Google Volley for web service calling (REST).

basically Volley is using SHA1 authentication(Basic Auth), But is there any way to modify with digest Auth (MD5).

Forde answered 16/12, 2015 at 6:11 Comment(2)
Have you seen this java2s.com/Open-Source/Android_Free_Code/Framework/platform/… ?Theodoratheodore
Thanks @Liberi for link... i hadn't checked yet... ill check it :)Forde
F
2

Both HTTP-authentications use simple header entities. I have not tried this by myself, but i assume all you need to implement is to provide header with Digest-specific format in your custom request like this:

public class MyRequest<T> extends Request<T> {
...
    @Override
    public Map<String,String> getHeaders() throws AuthFailureError {
        Map<String,String> headers = new HashMap<String,String>();
        headers.put("Authorization", "Digest " + getAuthorizationData());   
        return headers;
    }
...
}

I hope it'll help you

Fate answered 18/1, 2016 at 11:26 Comment(0)
I
2

The best solution for you is, indeed, use the HttpDigestStack. You can find the docs right here: http://www.java2s.com/Open-Source/Android_Free_Code/Framework/platform/com_gm_android_volleyHttpDigestStack_java.htm

All you have to do is to provide a new instance of a HttpDigestStack as an additional parameter when creating a new RequestQueue using Volley. You can follow this example:

Volley.newRequestQueue(context, new HttpDigestStack());
Impartible answered 19/1, 2016 at 15:24 Comment(1)
Unless I am misunderstanding something....This solution uses a deprecated method from BaseHttpStack (performRequest). Volley's recommendation suggests using executeRequest instead.Perquisite

© 2022 - 2024 — McMap. All rights reserved.