[GIS] How to Access Secured ArcGIS Online Services from a Custom JS Web app

arcgis-onlineauthenticationSecurity

I have some Layers Hosted on my company's ArcGIS Online Account. I want to make a Custom WebMapping Application hosted on our public server, which General Public can use without Logging in.

I'm trying to find some document or Example which shows how this can be done, but have drawn a Blank.

My Research so far:

1)Accessing secure ArcGIS Online map service from custom web mapping application? does not answer my question because I don't want my users to login to AGOL

2) https://developers.arcgis.com/documentation/core-concepts/security-and-authentication/accessing-arcgis-online-services/ Doesn't show how to create an App on an Organisation's ArcGIS Account.

What's the correct way to Access Secured ArcGIS Online Services from a Custom JS Web app?

Best Answer

If you have services that require authentication but you don't want your users to sign in, the best approach is to have your application handle the authentication for you. You do this by either setting up a proxy on your own server, or use a proxy service hosted by AGOL.

The first step is to create the actual application and register it with AGOL or your own portal. This can be done directly in AGOL or via the Developers site. If you are uncertain how, you can also try it by adding an item directly in AGOL by following the section for "Add Apps" in http://doc.arcgis.com/en/arcgis-online/share-maps/add-items.htm. This does the same thing as what is described in https://developers.arcgis.com/documentation/core-concepts/security-and-authentication/accessing-arcgis-online-services/.

Once the application is registered, you will need to take note of the client id and secret. This can be seen analogous to a username/password. These credentials would need to be stored in a proxy file that you have accessible (and also locked down) on your own server. More information on these proxies can be found at https://github.com/Esri/resource-proxy.

If you do not wish to host your own proxy file, you can use the hosted proxies. For example, let's say you are working with the route task which requires credentials. You can use use a hosted proxy service for the route task and reference that URL. More information on the proxy services an be found at https://developers.arcgis.com/documentation/core-concepts/security-and-authentication/working-with-proxies/.