Hosted feature layer not showing up

1212
3
09-10-2021 08:34 AM
AdaLi1
by
New Contributor III

I'm super new to ArcGIS API for Javascript so sorry for the stupid question... I'm trying to add a feature layer to my web map but my hosted feature layers (none are public) aren't showing up. If I add public layers from my organization, they do show up. What step am I missing?

Tags (1)
0 Kudos
3 Replies
Sage
by
New Contributor III

Hi @AdaLi1 ,

If the content isn't public you will need to authenticate your requests with ArcGIS Identity, an API Key or an OAuth2 Token.  A good introduction to security and authentication can be found here: https://developers.arcgis.com/documentation/mapping-apis-and-services/security/

 

JeffreyWilkerson
Occasional Contributor III

If you take any ArcGIS Javascript API example that adds a feature layer to a basemap and interchange that REST endpoint URL with one from an ArcGIS Online REST endpoint that is not publicly shared, then when you instantiate the page it will automatically ask you for your credentials. 

If the 'hosted feature layer' is not on ArcGIS  Online, but on an ArcGIS Server or Portal behind an agency firewall then you can't see it.  You could download a particular version of ArcGIS Javascript and serve it up from your local server and then access only your internal data if needed, and somewhere Esri has examples of how set up and use their Javascript API from your own server.

If the data is on ArcGIS Online, and is not publicly shared, but you want only certain people to access it you can share it up to an Online group, or specific accounts, and then those users will need to have an ArcGIS Online login.  Otherwise, if you want to handle the login and then push the data request through using a specific online account then you will have to useOAuth2 authentication as suggested by Sage.  

AdaLi1
by
New Contributor III

Thank you @Sage and @JeffreyWilkerson for your responses and links to the help docs! I saved my html file in our own server and used a OAuth2 token to get it to work. That was quite an authentication rabbit hole I didn't knew existed.

0 Kudos