AnsweredAssumed Answered

IdentityManager (3.16 vs 3.18) - How to find whether the map service is private or public?

Question asked by bforbhavin on May 23, 2018
Latest reply on May 23, 2018 by rscheitlin

ArcGIS Server supports private and public service both. How can I find out whether the map service is public or private in the code?


I have written code to perform silent authentication by avoiding to display the sign-in dialog. My expectation is to get an error then I can generate the token based on the error code.


This behavior I had implemented with ArcGIS Javascript API 3.16compact and it worked fine by querying to the mapservice url and generate token if it returns an error. But the same code doesn't work with 3.18compact. Because it challenges the user for credentials (in 3.18compact) and displays the sign-in dialog. So, the request doesn't go to error handler function. It appears the IdentityManager works different way in ArcGIS Javascript API 3.16 vs 3.18.


Notice the behavior in the following code by changing from 3.18 to 3.16 and vice versa.


<!DOCTYPE html>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">

<link rel="stylesheet" href="">
<link rel="stylesheet" href="">
html, body { height: 100%; width: 100%; margin: 0; padding: 0; }
#map{ margin: 0; padding: 0; }
#controls {
position: absolute;
height: 80px;
font-family: arial;
bottom: 10px;
margin: 5px;
padding: 5px;
z-index: 40;
background: #fff;
color: #444;
width: 440px;
left: 10px;
-moz-box-shadow: 0 0 5px #888;
-webkit-box-shadow: 0 0 5px #888;
box-shadow: 0 0 5px #888;
h3 { margin: 0 0 5px 0; border-bottom: 1px solid #444; }
.label { display: inline-block; width: 140px; }

<script src=""></script>
var app = {};

'esri/map', 'esri/layers/ArcGISDynamicMapServiceLayer', 'esri/tasks/GeometryService', 'esri/request', 'esri/tasks/ProjectParameters'
], function(
Map, ArcGISDynamicMapServiceLayer, GeometryService, esriRequest, ProjectParameters) { = new Map("map", {
basemap: 'streets'

//following is a private map service url
var vMapServiceUrl = "";

url: vMapServiceUrl,
content: { f: 'pjson'},
handleAs: 'json',
callbackParamName: 'callback'
}).then(function(results) {
var vDynamicLayer = new ArcGISDynamicMapServiceLayer(vMapServiceUrl, {
'id': 'AGSDynamicMapServiceLayer'
});;'layer-add-result', function(layer) {
if ( == 'AGSDynamicMapServiceLayer') {
var vGeometryService = new GeometryService(""),
vProjectParameters = new ProjectParameters();

vProjectParameters.geometries = [layer.layer.initialExtent];
vProjectParameters.outSR =;
vGeometryService.project(vProjectParameters, function (geometry) {[0], true);

}, function(errors) {
//expecting to get an error here for request made to private map service

<body class="tundra">
<div data-dojo-type="dijit.layout.BorderContainer"
style="width: 100%; height: 100%; margin: 0;">
<div id="map"