ArcGIS Maps SDKs and scripting APIs provide built-in functionality to implement user authentication. This typically comes in the form of an Authentication
or Identity
class, but Maps SDKs also provide automatic authorization for content items without requiring a class to be instantiated.
IdentityManager and AuthenticationManager
All ArcGIS APIs and SDKs provide a member class named Authentication
or Identity
that is used to implement user authentication. The implementation method varies based on the API or SDK you select.
const info = new OAuthInfo({
appId: "YOUR_CLIENT_ID",
});
esriId.registerOAuthInfos([info]);
esriId
.checkSignInStatus(info.portalUrl + "/sharing")
.then(() => {
handleSignedIn();
})
.catch(() => {
handleSignedOut();
});
document.getElementById("sign-in").addEventListener("click", function () {
esriId.getCredential(info.portalUrl + "/sharing");
});
document.getElementById("sign-out").addEventListener("click", function () {
esriId.destroyCredentials();
window.location.reload();
});
let map;