Accessing secured FeatureLayer on ArcGIS online with JavaScript API

751
2
06-08-2021 01:30 AM
IvoSturm
New Contributor II
Hi experts,
 
I am building a web app outside of ArcGIS. I am connecting the web app with ArcGIS online resources via the ArcGIS JavaScript API v4.19, which all goes pretty smoothely.
 

The challenge arises when I want to load specific secured ArcGIS online content via the ArcGIS JavaScript API, specifically from some FeatureLayers which are secured. I looked into the documentation and it seems the best way forward would be a so-called 'application login'. For this I want to setup an OAuth application login based on Client ID and Client Secret. With these two I can get a valid token via OAuth and use that token to access the content by feeding the token to the IdentityManager via the JavaScript API.

The problem I have is that I am continously getting the same error with name identity manager not authorized and message You are currently signed in as: AppID. You do not have access to this resource: 

So this is were it goes wrong currently, I can't seem to figure out where to make it explicit on the ArcGIS online side that this specific secured FeatureLayer can be accessed via this application login, hence currently I am getting errors that the valid token and app id don't have access to the resource, being the end-point of the secured FeatureLayer.

Does anybody know how to associate a secured FeatureLayer in ArcGIS online to an application login?

 

0 Kudos
2 Replies
IvoSturm
New Contributor II

Anybody? Sounds like a very common use case, so eager to hear from other peoples experience.

0 Kudos
PhilLarkin1
Occasional Contributor III
0 Kudos