Yor code is ok. you have the http client setup configured and the header added correctly. but. your basic authentication is incorrect. the header key (Authentication) is right, but the value must be Basic + Base64.encode (username + ":" + pass)
also an alternative to this is the following code:
httpclient.getCredentialsProvider().setCredentials( new AuthScope(targetHost.getHostName(), targetHost.getPort()), new UsernamePasswordCredentials("username", "password"));
The target hostname is probably null and port is -1.
but this one that you cannot use if you use a URL connection, so the header is also acceptable.
EDIT:
HERE IS YOUR QUESTION:
String auth = android.util.Base64.encodeToString( ("florin999@zitec.ro" + ":" + "test2323" + ":" + "zitec" + ":" + "7716099f468cc71670b68cf4b3ba545c5760baa7") .getBytes("UTF-8"), android.util.Base64.NO_WRAP);
What are all these concatenations?
Basic authentication means adding an authentication header with base64 encoding, which is the word of the word "Basic " + Base64.encodeToString("yourUsername"+":"+"yourPassword)
An alternative is to add the method i inserted at the top of the credential provider in the same way
DArkO
source share