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.