AnsweredAssumed Answered

Using Feature Layer from ArcGIS Online in ArcGIS Javascript

Question asked by BrokenLegMike on Feb 13, 2019
Latest reply on Feb 15, 2019 by odoe

I'm playing around with the Javascript API for ArcGIS and wanted to use a feature layer from my Enterprise ArcGIS Online account. The script is quite simple, basically, create a map and add the feature layer. When I launch the webpage, the base map is populated and then I get a prompt to log into ArcGIS (see image below). I enter my enterprise credentials and it it tells me they are incorrect. My assumption is, that it's looking for credentials for a regular ArcGIS Online account ( as opposed to my enterprise account. So, my question is, how would I configure my Javascript to prompt me to log into my enterprise account. For reference, here is my code:


<!DOCTYPE html>
  <meta charset="utf-8">
  <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
  <title>Intro to FeatureLayer - 4.10</title>

  <link rel="stylesheet" href="">
  <script src=""></script>

    #viewDiv {
      padding: 0;
      margin: 0;
      height: 100%;
      width: 100%;

        Map, MapView,
      ) {

        var map = new Map({
          basemap: "hybrid"

        var view = new MapView({
          container: "viewDiv",
          map: map,

          extent: { // autocasts as new Extent()
            xmin: -9177811,
            ymin: 4247000,
            xmax: -9176791,
            ymax: 4247784,
            spatialReference: 102100

         * Add feature layer

        // Sample Feature Layers
        var featureLayer = new FeatureLayer({
          url: ""



  <div id="viewDiv"></div>