Created
July 29, 2021 13:31
-
-
Save ca0v/1c2b199cc3aa548cdf07d1d482bf8d47 to your computer and use it in GitHub Desktop.
Esri Case #02854773
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"> | |
<title>Persisting Identity Manager Info</title> | |
<link rel="stylesheet" href="https://js.arcgis.com/3.37/dijit/themes/tundra/tundra.css"> | |
<link rel="stylesheet" href="https://js.arcgis.com/3.37/esri/css/esri.css"> | |
<style> | |
html, | |
body { | |
height: 100%; | |
width: 100%; | |
margin: 0; | |
padding: 0; | |
} | |
</style> | |
<script src="https://js.arcgis.com/3.37/"></script> | |
<script> | |
require([ | |
"dojo/_base/unload", | |
"dojo/cookie", | |
"dojo/io-query", | |
"dojo/json", | |
"dojo/parser", | |
"esri/config", | |
"esri/IdentityManager", | |
"esri/arcgis/OAuthInfo", | |
"esri/layers/FeatureLayer", | |
"esri/map", | |
"dijit/layout/BorderContainer", | |
"dijit/layout/ContentPane", | |
"dojo/domReady!", | |
], function ( | |
baseUnload, | |
cookie, | |
ioquery, | |
JSON, | |
parser, | |
esriConfig, | |
esriId, | |
OAuthInfo, | |
FeatureLayer, | |
Map) { | |
function doit() { | |
alert("creating map"); | |
const map = new Map("mapCanvas", { | |
basemap: "topo", | |
center: [-115.3, 36.2], | |
zoom: 12 | |
}); | |
const secureLayer = new FeatureLayer("https://usalvwdgis1.infor.com/server/rest/services/IPS112/SQL2v112/FeatureServer/0", | |
{ | |
mode: FeatureLayer.MODE_ONDEMAND, | |
outFields: ["*"] | |
}); | |
map.addLayer(secureLayer); | |
} | |
parser.parse(); | |
// initialize based on this application identifier | |
const info1 = new OAuthInfo({ | |
appId: "q6iem1U8P0gCNkqz", | |
portalUrl: "https://usalvwdgis1.infor.com/portal", | |
popupCallbackUrl: "oauth-callback.html", | |
popup: true | |
}); | |
const info2 = new OAuthInfo({ | |
appId: "9NUqUHlbjD862IX3", | |
portalUrl: "https://usalvwdgis1.infor.com/portal", | |
popup: false | |
}); | |
esriId.registerOAuthInfos([info1]); | |
esriId.on("credential-create", event => { | |
console.log("credential", event.credential); | |
const expires = event.credential.expires; | |
cookie("esri-access-token", event.credential.token, { expires }); | |
}); | |
esriId.setOAuthRedirectionHandler((info) => { | |
console.log("setOAuthRedirectionHandler", { info }); | |
window.location = info.authorizeUrl + "?" + ioquery.objectToQuery(info.authorizeParams); | |
}); | |
esriId.checkSignInStatus(info1.portalUrl + "/sharing") | |
.then(() => { | |
doit(); | |
}) | |
.otherwise(() => { | |
window.addEventListener("arcgis:auth:hash", (event) => { | |
esriId.setOAuthResponseHash(event.detail); | |
doit(); | |
}); | |
esriId.getCredential(info1.portalUrl + "/sharing"); | |
}); | |
}); | |
</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> | |
</div> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script> | |
function loadHandler() { | |
opener.dispatchEvent(new CustomEvent("arcgis:auth:hash", { detail: location.hash })); | |
close(); | |
} | |
</script> | |
</head> | |
<body onload="loadHandler();"></body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment