Hello,
I'm trying to implement OAuth login for my web app. I followed the API sample here : Access ArcGIS Online items using OAuthentication | ArcGIS API for JavaScript 4.4 . It works for me when I open the live demo, but when I download the file and open it in chrome locally. I got this error:
How should I fix this?
thanks!
You need to update it with your own appId and set up the redirect to your dev machine.
Hello Rene,
thanks for the reply. I tried that already. But the error is the same. I am confused that should I modify the code
esriId.getCredential(info.portalUrl + "/sharing")
? I replace this code with
window.open('https://www.arcgis.com/sharing/rest/oauth2/authorize?client_id='+clientId+'&response_type=token&expi...' + window.encodeURIComponent(redirectUri), 'oauth-window', 'height=400,width=600,menubar=no,location=yes,resizable=yes,scrollbars=yes,status=yes')
And it works. But I do not want hard code this directURL. What should I do?
Whitney
Go to your Online page, something <user>.arcgis.com, go to Content, filter by Apps/Registered Apps
Click on your app, go to settings.
Under settings, go to Application Settings area and click on Registered Info button.
Update the URI redirects here, this is what one of mine looks like.
Hi Rene,
Thanks for the instruction. Similarly, I added my portals in the app
esriId.getCredential(info.portalUrl+"/sharing");
The getCredential function now works and showing the AGOL login form
However, after the login, nothing happens.
esriId.checkSignInStatus(portalUrl+"/sharing").then( function() {
//displayItems();
alert("ssss");
}).otherwise( function() {
// Anonymous view
domStyle.set("anonymousPanel", "display", "block");
domStyle.set("personalizedPanel", "display", "none");
}
);
Neither the resolved or rejected function executes after a successful login.
Should I change the parameter (portalUrl+"/sharing") to somthing else?
Also, after I login and direct to another html page that also requires some feature access, how can I check it is already login and avoid a second login?
Whitney