Extracting helper function for making authenticated HTTPS requests.