2

I am trying to embed a web map from ou ArcGIS Online on our corporate web app.

I implemented a server-side token generator, since our app users do not have (and should not have) an ArcGIS Online account, only the server.

However, I could not find a way to authenticate through the JS API using only a token or setting a custom getToken function.

I tried to simply add the token to the layer url, but it opened the login popup nonetheless.

const testLayer = new FeatureLayer({
        url: "https://services3.arcgis.com/.../ArcGIS/rest/services/.../FeatureServer/0?token=..."
      });

Ideally I also want the Javascript to able to access an ArcGIS Online item using only the token, for example a web map JSON.

I'm using ArcGIS API for Javascript 4.

1 Answer 1

3

In the 4x JSAPI, unknown properties can't be added to the URL like that.

Instead, you can use "interceptors" to add any custom logic to the requests being sent (and retrieved) by the API. For example, to modify the URL. https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#request

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.