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);
}
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With