Adding a token to feature layer URL not hosted on an arcgis server

1262
1
11-30-2018 09:01 AM
DanielBen
New Contributor

I am trying to add a Feature Layer to my application that sources data from a FeatureServer URL that is hosted internally, not on an ArcGIS server.  The URL requires authentication to access, either through a token parameter or an authorization header.  How do I have ArcGIS JS (4.8) add the token to the URL when creating the feature layer?  I have tried IdentityManager.initialize and the token property on the FeatureLayer object with no luck.  Most information on how to authenticate requests is specifically for authenticating to an ArcGIS hosted resource, not something hosted elsewhere.

The other tool we're using is a Node Express server hosting data from a MarkLogic database server as Feature Layers, koop-provider-marklogic.  Without authentication enabled everything works fine, but that's less than ideal for security reasons.

0 Kudos
1 Reply
Noah-Sager
Esri Regular Contributor

Daniel Ben I'm not 100% sure, but this sounds like a good use case for RequestInterceptors. This would allow you to add a token parameter or an authorization header.

esriConfig.request.interceptors:

config | API Reference | ArcGIS API for JavaScript 4.10