Hi, I'm trying to authenticate on my jira server from java with the code below. I got few concerns about the baseURL, not sure how to connect and wich loginUsername and password to use since basic auth is no longer supported. ATM i'm using OAuth credentials created via web gui on JIRA. If trying to use port 8080 i get conn timeout. Using JIRA SERVER not Cloud. Need some help to use REST API pls
public static void main(String[] args) {
String baseURL = "https://alestar.atlassian.net/jira/rest/";
String loginUserName = "user";
String loginPassWord = "password";
URL url = null;
HttpURLConnection conn = null;
String input = "";
OutputStream os = null;
BufferedReader br = null;
String output = null;
try {
url = new URL(baseURL);
conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/json");
input = "{\"username\":\"" + loginUserName + "\", \"password\":\"" + loginPassWord + "\"}";
os = conn.getOutputStream();
os.write(input.getBytes());
os.flush();
if (conn.getResponseCode() == 200) {
br = new BufferedReader(new InputStreamReader((conn.getInputStream())));
while ((output = br.readLine()) != null) {
}
conn.disconnect();
}
System.out.println("HTTP " + conn.getResponseCode());
} catch (Exception ex) {
System.out.println("Error in loginToJira: " + ex.getMessage());
}
}