
Android Studio Dev - Volley - basic http auth
Jak vyřešit v android aplikaci http autorizaci při použití balíčku volley?
public static final String BASIC_AUTH = "username:password"
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> headers = new HashMap<>();
// http basic auth
String auth = "Basic " + Base64.encodeToString(Constants.BASIC_AUTH.getBytes(), Base64.NO_WRAP);
headers.put("Authorization", auth);
return headers;
}
// fix error: Unexpected char 0x0a at 44 > replace Base64.DEFAULT with Base64.NO_WRAP
String auth = "Basic " + Base64.encodeToString(Constants.BASIC_AUTH.getBytes(), Base64.NO_WRAP);