I need to connect to an API through https but it needs authorisation. 
I have the login name and password for it, but have no idea how to transfer it to https.
The code I tried to use the following code (which got from another SO post):
public class TestHTTPSRequest {
public static void main(String[] args) throws Exception {
    URLConnection connection = new URL("https://smartcat.ai/api/integration/v1/account").openConnection();
    InputStream is = connection.getInputStream();
    InputStreamReader reader = new InputStreamReader(is);
    char[] buffer = new char[256];
    int rc;
    StringBuilder sb = new StringBuilder();
    while ((rc = reader.read(buffer)) != -1)
        sb.append(buffer, 0, rc);
    reader.close();
    System.out.println(sb);
}
}
 
     
    