I am looking to fetch some ArcGIS FeatureLayers
from arcgis.com which are secured, using the JS 4.0 API. If I include them as normal, I get the pop-up window to allow users to log in. Ideally, this needs to use application authentication so end-users do not need to log in each time.
I have the App ID and App Secret details and can generate a token. If I append the token to the URL when making the new FeatureLayer
, the first call is successful and I can see the token is sent through. But when that first call is completed, a second call is made to the /query method - this call no longer includes the token, which then fails the authentication and brings up the login window.
I am currently doing:
var layer = new FeatureLayer({
url: "featureserverurl?token=token"
});
I have tried to pass the token through as a second option, though this is then never picked up on any of the requests. Is there something that I'm missing?