Given that I am on 4.x of the JS SDK, I am struggling to find some example code of how I would authenticate requests made to the ArcGIS hosted layers that I have made private (but is shared within my organization).
I am able to find several examples of enabling users to enter username and passwords, and the default behavior of a "private" feature layer is to pop a dialog box asking for user credentials - but this is not the desired workflow for my application.
I've found mention of a few approaches, but have found next to nothing in code examples for the JS 4.x SDK in how to pull this off (I even have the IdentityManager documentation up, but haven't been able to find example code leveraging it with app auth). Here's what I've found, with the first being preferred:
- Prior to loading the private feature layers, the JS 4.x SDK is used to query the ArcGIS server, and thanks to the whitelisted referrers, it is given some sort of authorization token that allows future private feature layer requests to succeed.
- Prior to loading the private feature layers, the JS 4.x SDK queries our backend server that leverages .NET Core, which makes a request to the proxy application on the ArcGIS servers, and then returns some sort of authorization token to the client, which allows future private feature layer requests to succeed
The second approach is obviously more difficult to implement, because not only will it likely be a longer request to complete as far as the client is concerned, the code that Esri provides does not work on .NET Core, so I'd be working off of some branched code that fellow Esri customers have provided on Github (not ideal).