Send authentication information with Volley request

前端 未结 3 960
执念已碎
执念已碎 2020-12-10 05:24

In my Android app I have to call a web service which looks like this

http://mywesite.com/demo/mob/getmenubycategory/1

I am using the volle

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-10 05:57

    just override this method

     @Override
            public Map getHeaders() {
                String username ="danish@gmail.com";
                String password = "dani3173";
                String auth =new String(username + ":" + password);
                byte[] data = auth.getBytes();
                String base64 = Base64.encodeToString(data, Base64.NO_WRAP);
                HashMap headers = new HashMap();
                headers.put("Authorization",base64);
                headers.put("accept-language","EN");
                headers.put("Content-type","application/json");
                headers.put("Accept","application/json");
                return headers;
            }
    

提交回复
热议问题