<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <meta http-equiv="X-UA-Compatible" content="IE=7" /> <title>Persisting Identity Manager Info</title> <link rel="stylesheet" href="https://community.esri.com//serverapi.arcgisonline.com/jsapi/arcgis/3.2/js/dojo/dijit/themes/tundra/tundra.css"> <link rel="stylesheet" href="https://community.esri.com//serverapi.arcgisonline.com/jsapi/arcgis/3.2/js/esri/css/esri.css" /> <style type="text/css"> html, body { height: 98%; width: 99%; margin:0; padding-top:4px; padding-left:4px; } #rightPanel{ width:140px; border:2px solid #617798; -webkit-border-top-right-radius: 4px; -webkit-border-bottom-right-radius: 4px; -moz-border-radius-topright: 4px; -moz-border-radius-bottomright: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; } #mapCanvas{ border-top:2px solid #617798; border-bottom:2px solid #617798; border-left:2px solid #617798; -webkit-border-top-left-radius: 4px; -webkit-border-bottom-left-radius: 4px; -moz-border-radius-topleft: 4px; -moz-border-radius-bottomleft: 4px; border-top-left-radius: 4px; border-bottom-left-radius: 4px; padding:0px; } .templatePicker{ height:80%; } </style> <script>var dojoConfig = { parseOnLoad: true };</script> <script src="//serverapi.arcgisonline.com/jsapi/arcgis/3.2/"></script> <script type="text/javascript"> dojo.require("dijit.layout.BorderContainer"); dojo.require("dijit.layout.ContentPane"); dojo.require("esri.map"); dojo.require("esri.layers.FeatureLayer"); dojo.require("esri.IdentityManager"); var map, cred = "esri_jsapi_id_manager_data"; // cookie/local storage name function init() { // store credentials/serverInfos before the page unloads dojo.addOnUnload(storeCredentials); // look for credentials in local storage loadCredentials(); esri.config.defaults.io.proxyUrl = "http://ogi.oa.mo.gov/proxy/proxy.ashx"; /* map = new esri.Map("mapCanvas",{ extent: new esri.geometry.Extent({"xmin":-12080521,"ymin":4472736,"xmax":-11829657,"ymax":4563023,"spatialReference":{"wkid":3857}}) }); */ var spatialReference = new esri.SpatialReference({ wkid: 102100 }); startExtent = new esri.geometry.Extent(-10723197, 4186914, -9829190, 4992866, spatialReference); map = new esri.Map("mapCanvas", { extent: startExtent }); dojo.connect(map, "onLoad", function() { dojo.connect(dijit.byId('mapCanvas'), 'resize', map,map.resize); }); var basemap = new esri.layers.ArcGISTiledMapServiceLayer("https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"); map.addLayer(basemap); var countyLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://myserver.mo.gov/arcgis/rest/services/county_simple/MapServer"); map.addLayer(countyLayer); var serverLayer = new esri.layers.FeatureLayer("https://myserver.mo.gov/ArcGIS/rest/services/myservice/MapServer/1",{ mode:esri.layers.FeatureLayer.MODE_ONDEMAND, outFields:["*"] }); map.addLayer(serverLayer); } function loadCredentials() { var idJson, idObject; if ( supports_local_storage() ) { // read from local storage idJson = window.localStorage.getItem(cred); } else { // read from a cookie idJson = dojo.cookie(cred); } if ( idJson && idJson != "null" && idJson.length > 4) { idObject = dojo.fromJson(idJson); esri.id.initialize(idObject); } else { console.log("didn't find anything to load :("); } } function storeCredentials() { // make sure there are some credentials to persist if ( esri.id.credentials.length === 0 ) { return; } // serialize the ID manager state to a string var idString = dojo.toJson(esri.id.toJson()); // store it client side if ( supports_local_storage() ) { // use local storage window.localStorage.setItem(cred, idString); // console.log("wrote to local storage"); } else { // use a cookie dojo.cookie(cred, idString, { expires: 1 }); // console.log("wrote a cookie :-/"); } } function supports_local_storage() { try { return "localStorage" in window && window["localStorage"] !== null; } catch( e ) { return false; } } dojo.ready(init); </script> </head> <body class="tundra"> <div data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="design:'headline',gutters:false" style="position:relative;width:100%;height:100%;"> <div id="mapCanvas" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'center'"> </div> <!--right content panel--> <div id="rightPanel" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'right'"> <p> This sample shows how to view a secure map service using token-based authentication. Use the following credentials to test the application:</br> User Name: <b>rick</b></br>Password: <b>rick@esri</b> </p> <div id="content" style="height:100%;"></div> </div> </div> </body> </html>
Solved! Go to Solution.
esri.config.defaults.io.proxyUrl = "https://ogitest.oa.mo.gov/proxy/proxy.ashx"; var serverInfo = new esri.ServerInfo(); serverInfo.server = 'https://ogi.oa.mo.gov'; serverInfo.tokenServiceUrl = 'https://ogi.oa.mo.gov/arcgis/tokens/generateToken';
<serverUrl url="https://sampleserver6.arcgisonline.com/arcgis/rest/services/" matchAll="true"></serverUrl>
https://servicesbeta.esri.com/ArcGIS/rest/services/SanJuan/TrailConditions/FeatureServer/0
Looks like this service, used by the sample is no longer available.