Skip to content

Instantly share code, notes, and snippets.

@phpmaps
Created May 29, 2013 22:20
Show Gist options
  • Save phpmaps/5674308 to your computer and use it in GitHub Desktop.
Save phpmaps/5674308 to your computer and use it in GitHub Desktop.
OAuth workflow using ArcGIS API for JavaScript
dojo.require("esri.arcgis.Portal");
dojo.require("app.OAuthHelper");
dojo.ready(initialize);
function initialize() {
OAuthHelper.init({
appId: "q244Lb8gDRgWQ8hM",
portal: "http://www.arcgis.com",
expiration: (14 * 24 * 60), // 2 weeks, in minutes
popup: false
});
if (OAuthHelper.isSignedIn()) {
displayItems();
}
else {
// Anonymous view
dojo.style(dojo.byId("anonymousPanel"), "display", "block");
dojo.style(dojo.byId("personalizedPanel"), "display", "none");
}
}
function signIn() {
OAuthHelper.signIn().then(displayItems);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment