import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; import org.json.JSONObject; //https://github.com/douglascrockford/JSON-java public class Sample { public static void main(String[] args) { String key = "YOUR API KEY HERE"; String secret = "YOUR API SECRET HERE"; String url = "https://apicurrent-app.booker.ninja/WebService4/json/CustomerService.svc/access_token?client_id="+key+"&client_secret="+secret+"&grant_type=client_credentials"; URL request = null; try { request = new URL(url); } catch (MalformedURLException e) { e.printStackTrace(); } String line; StringBuilder response = new StringBuilder(); URLConnection connection = null; try { connection = request.openConnection(); connection.setDoOutput(true); BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); while((line = reader.readLine()) != null) { response.append(line); } } catch (IOException e) { e.printStackTrace(); } JSONObject json = new JSONObject(response.toString()); String token = (String)json.get("access_token"); System.out.println(token); } }