I need to do some Assembla authentication before those I distribute my program to, can use login and use it.
But I am having some issues with how I use the Assembla API as I've never really used a REST HTML API in Java before.
I need to fetch all the spaces that the user is a member of, and then figure out if the user is part of any of the spaces that I've set up so that I can allow them into the application. On the website it seems I would use this:
http://api-doc.assembla.com/content/ref/spaces_index.html
But how do I use this exactly? I get that I need to make an HTTP GET request, but I have no idea how to form the request properties in Java.
I got this so far:
String authentication = "username:password";
String encoding = Base64.getEncoder().encodeToString(authentication.getBytes());
URL url = new URL("https://www.assembla.com/");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("Authorization", "Basic " + encoding);
conn.connect();
for (Entry<String, List<String>> header : conn.getHeaderFields().entrySet()) {
System.out.println(header.getKey() + "=" + header.getValue());
}
Any help?