I am trying to add KML Layers to the ArcGIS JS API. I have the KML layers hosted on the ArcGIS Online server. This data that I am working with contains some sensitive information and I am trying to use them within a web application that I am creating using JS (includes jQuery), CSS, and HTML. In order for me to see these layers within the web app it appears that they need to be shared publicly on ArcGIS Online. I do not want to do that because of the sensitive content of them, however I am allowed to share them within my Organization or Group on ArcGIS Online.
Unfortunately, the API doesn't recognize my permissions within these groups, and won't display the KML layers. Is there any way that I can get the ArcGIS JS API to recognize my credentials and allow me to view the layers without sharing them with everyone (public)? In other words is there any way that I can leave them shared within the Organization and/or Group and still see them within my web application using the API?
Additionally I am using Google Earth API that has the same issues, a solution to that would be helpful too.