AnsweredAssumed Answered

Connecting to secure map service within javascript app

Question asked by djh78 on Mar 2, 2020
Latest reply on Mar 3, 2020 by djh78



I have read all kinds of help documentation on this subject but can't seem to find the best fit, or get any to work. I have written the javascript app below. The layer being used is secured as I would not want the contents being made available to everyone, except for people who are using the app. They will have already logged in to get this far so I just need the application to handle the logging in to get the map data back. (ie at the moment it asks for an ArcGIS server log in). I can find lots of information about accessing secure applications, but not specific layers within a javascript app...any help would be great.


    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>DH Test Map</title>
      html, body, #viewDiv {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
 <link rel="stylesheet" href="">
 <script src=""></script>
    ], function(WebMap, MapView, FeatureLayer, urlUtils, Query) {
     var urlObject = urlUtils.urlToObject(document.location.href);
    var impactedPropertiesLayer = new FeatureLayer({
   url: "https://MYENTERPRISESERVER/server/rest/services/TEST/AffectedPropertiesSecure/MapServer/0",
   popupTemplate: { title: "{UPRN}", content: "{ImpactLevel_ID}"},
  impactedPropertiesLayer.when(function() {
   return impactedPropertiesLayer.queryExtent();
   }).then(function(response) {

  var webmap = new WebMap({
   portalItem: {
     id: "1a409e5d6939452cbb27fee5f05a2140"

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


 var expression;
 function runValidaty(UrlPropertiesObj){
 expression ="";
 Object.keys(UrlPropertiesObj.query).forEach(function(key,index) {
 var objectValue = UrlPropertiesObj.query[key];
 //first time round
 expression += key + "="+objectValue+"";
 expression += key + "='"+objectValue+"'";
 var nextObj = Object.keys(UrlPropertiesObj.query)[index+ 1];
  //yes there is a property in the next loop
  expression += "AND "

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