We're trying to embed a web map from ou ArcGIS Online on our corporate web app.
So we implemented a server-side token generator, since our app users don't have (and shouldn't) a ArcGIS Online account, only the server through a client_id and client_secret.
But I couldn't 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 :
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.
Using ArcGIS Javascript API 4