Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Basic Authentication not working from Android to Sharepoint 2013

I have been trying since two days to set basic authentication from my android application to SharePoint 2013. I have used HttpUrlConnection,DefaultHttpClient,Retrofit and Volley but these all are showing Authorization failure error. Which is working fine in iOS application.Below is my Vollery code snippet.

private void sendJsonrequestSignIn(final String userName, final String password) {
    StringRequest stringRequest = new StringRequest(Request.Method.GET, "http://192.168.50.31/sites/MobileDev/_vti_bin/listdata.svc/TestData",
            new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    Log.i("ResponseJson", response.toString());
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    //Log.i("ErrorJson", error.getMessage());
                    Toast.makeText(MainActivity.this, error.toString(), Toast.LENGTH_LONG).show();
                }
            }) {

        @Override
        public Map<String, String> getHeaders() throws AuthFailureError {
            HashMap<String, String> params = new HashMap<String, String>();
            String creds = String.format("%s:%s", userName, password);
            String auth = "Basic " + Base64.encodeToString(creds.getBytes(), Base64.NO_WRAP);
            params.put("Authorization", auth);
            params.put("Accept", "application/json;odata=verbose");
            return params;
        }

    };
    requestQueue.add(stringRequest);
}
like image 788
Satheesh Avatar asked Aug 19 '16 10:08

Satheesh


People also ask

How does basic authentication that can be set at the Web server level work?

Basic authentication sends user names and passwords over the Internet as text that is Base64 encoded, and the target server is not authenticated. This form of authentication can expose user names and passwords. If someone can intercept the transmission, the user name and password information can easily be decoded.

How do I enable basic authentication?

You can enable Basic Auth support for a tenant from the Azure portal (Azure Active Directory -> Properties -> Manage Security defaults -> Enable Security defaults = No). Note a number of options under Allow access to basic authentication protocols.

What is the difference between basic auth and modern Auth?

Basic Authentication is an older version of the password exchange for Microsoft platforms, and a less secure mechanism. It is being replaced with the Microsoft implementation of Modern Authentication (OAuth), which is the newer and more secure version of authentication to Microsoft platforms.


1 Answers

Have you tried Jshare. This library supports NTLM and works with Java and Android. I guess this might help with the NTLM authentication in your app.

like image 126
Neji Avatar answered Sep 23 '22 13:09

Neji