I grabbed the basic oath sample for the 3.23 API from here: https://developers.arcgis.com/javascript/3/jssamples/portal_oauth_inline.html
set the portal url to our internal Portal for ArcGIS and it worked. Next, I upgraded it to the 4.6 API and now it no longer works. I get no errors in the console, it does redirect to the oath page and allow me to login, but it just does not reload the page afterwards. I tried both inline and popup, same result.
Solved! Go to Solution.
Seems like this sample still points to Arcgis Online even when you set the portalUrl. To fix this I set the esriConfig.portalUrl = info.portalUrl after including the esri/config module. This should make the sample point to your portal and allow you to view the items.
Brain,
Have you looked at the 4.x docs for the IdentityManager class?
IdentityManager | API Reference | ArcGIS API for JavaScript 4.6
Most code/sample do not work by just changing the api version (a lot has changed between the two).
Yes I scanned the docs, looked for new sample code, etc. I didn’t find an equivalent sample for the 4.6 API so that’s when I opted to port the old sample over. First, I compared the classes and methods and determined they have not changed as far as I can tell.
It would be pretty helpful to put a link to this sample in the IdentifyManager and OAuthInfo classes.
Rene,
Thank you for finding the sample for 4.6. I downloaded it, pointed it to my Portal and did get a slightly different outcome. It does let me login to the oath page, but then the page background turns grey and small dialog box prompt me to login again. The identity manager never redirects back to the web page like it should. Another clue is I can see the get request from the IdentityManager going to the server and it looks like this:
https://[ourportal]/arcgis/sharing/rest?f=json&token=[long token string]
The response to the request is http 200 with this in the body:
{"currentVersion":"5.1"}
Did you change the appId value? You'll have to set one up for your application. Implementing App Login | ArcGIS for Developers
Ken,
Yes I did. The appID and portal url work fine with the 3.23 sample.
Seems like this sample still points to Arcgis Online even when you set the portalUrl. To fix this I set the esriConfig.portalUrl = info.portalUrl after including the esri/config module. This should make the sample point to your portal and allow you to view the items.