We are having issue with HttpURLConnection + Basic authentication when we have lengthy passwords.
Here is the sampple code:
URL url = new URL("http://localhost/data.json");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod(method);
String authString = clientId + ":" + clientSecret;
BASE64Encoder encoder = new BASE64Encoder();
String authHeader = encoder.encode(authString.getBytes());
conn.setRequestProperty("Authorization", authHeader);
conn.setRequestProperty("Accept", "application/json");
We tried to use
String authString = clientId + ":" + clientSecret;
authString = "" + javax.xml.bind.DatatypeConverter.printBase64Binary(authString.getBytes());
But no luck with this.
HttpURLConnection with Basic Auth with passswords of certain length working fine but with lengthy passwords we have issue. And the error code returned is 400
Note: This is related to Login with Paypal integration https://developer.paypal.com/webapps/developer/docs/integration/direct/log-in-with-paypal/detailed/#making-first-call
and the sample code we have (provided by PayPal) also not working.
thank you in advance.