[ardoHTTP] Preemptive Auth

Forge Component
Published on 2019-01-20 by Ricardo Silva
21 votes
Published on 2019-01-20 by Ricardo Silva

I am trying to hit a URL which requires Preemptive Auth.
When I try to test this from SoapUI, I get a good response.

While using HTTPPost with the username and password, it does not get authenticated.
Can you please help?

Note: I am using POST query string to post the request (as per the requirement of the service)
something like https://serviceurl/serviceServlet?mydata=ENCODEDxmlRequest
Hello Goldy,

I double-checked the Java code and it's always doing preemptive authentication (sending the Authorization header in the first request) if a username is provided:

// pre_auth is always true
if (pre_auth && !username.equals("")) {
connection.setRequestProperty("Authorization", "Basic " + base64Encode(username + ":" + password));

So, the only things I can think of for this not working are the following:

1) username / password are invalid
2) your service does not accept Basic HTTP Authentication.
3) empty username?

In order to troubleshoot this, it would be useful to get a Request / Response pair (just the headers might be sufficient) to better understand what's going on.