Hi everyone, so I have an Organization ArcGIS online account with a creator user type. I'm trying to access the hosted feature layer stored in the account and I need help with authenticating and identifying the app.
I'm having trouble with my code, when I click on the sign-in button, nothing happens. For the OAuth 2.0 application which I created, I have set the redirect URL to http://localhost:3000 . Also, is there a way to make the sign-in button disappear after the user has signed in?
"document.getElementbyID" is misspelled, so that event listener is never applied. You have to use the correct case in JavaScript, so that should be "document.getElementById". Make sure you check the browser's developer tools to catch mistakes like this.
You can use code like this to hide or display elements
document.getElementById("sign-in").addEventListener("click", () => {
document.getElementById("sign-in").style.display = "none";
document.getElementById("sign-out").style.display = "block";
esriId.getCredential(info.portalUrl + "/sharing");
});
document.getElementById("sign-out").addEventListener("click", () => {
esriId.destroyCredentials();
document.getElementById("sign-in").style.display = "block";
document.getElementById("sign-out").style.display = "none";
});
Hi @KenBuja omgg thank you so much! I fixed the error but when i click on it, it says www.arcgis.com refused to connect
Have you read the developer help about setting up authentication?
One more thing...take a look at a recent blog that @ReneRubalcava3 wrote about authentication code in JavaScript.