I have example code that will do a POST to authenticate to my server. That works and is as far as I can get, I have not figured out how to make subsequent calls using the connection that is returned.
After the POST, I want to do a GET. As I understand it, I must save or use the returned cooking for subsequent calls if I want to do a GET.
Does anyone have a simple single file .java example of doing a POST to authenticate to the server and then doing a GET with the connection that is returned?
I cannot find an example of this anywhere in any documentation or site, but it seems like a very common thing that would be done.
Any help would be greatly appreciated. If there are dependencies, inncluding a pom.xml would be extremely helpful.
byte creds = ("superuser:superuser").getBytes("utf-8"); String jasperAuth = "Basic " + Base64.getEncoder().encodeToString(JasperCred); URL url = new URL("http://localhost:8080/jasperserver-pro"); HttpURLConnection con = (HttpURLConnection) url.openConnection(); con.setRequestProperty("Authorization", jasperAuth); con.setRequestMethod("POST");
now I have a connection 'con', and want to do another GET and possibly more POST's
How does one auth with POST, and then do a subsequent GET?
I am assuming the POST would save a cookie that I can use in the GET so I would not have to auth with the GET?
I do not want to auth via GET because the user login/password would/could be saved in server log files and is an insecure approach.