Help please!
I am trying add a layer to a map using the JS API 4.x. This layer is a feature layer and it has a token to access to it.
In the Esri Javascipt I was add the layer just by specifying the token in the URL.
I am trying to do the same in 4.x however the app is always asking me for a user and password even if I already attached a valid token to the URL.
var myUrl = 'www.randomAddress.com';
var token = 'xioxioxioxioxioxioxioxioxio............'
var featureLayer = new FeatureLayer({
url: myURL + "?token=" + token
});
Is there a new way to do this in 4.x?
I am attaching the code of the app and also an screenshot. Thank you very much!
Cesar,
The FeatureLayer Class has a token property.
https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#token
var featureLayer = new FeatureLayer({
url: myURL
});
featureLayer.token = token;
Nice!, i was wondering if that was added in the 3.20 version but no.
FeatureLayer | API Reference | ArcGIS API for JavaScript 3.20
You could probably just add the token parameter and value to the service URL e.g. [URL] + "&token=abc123"
I tried this before and I had the same problem.
Thank you!
Hello Robert,
Thank you very much for your response. I actually tried this before and I just did it again however I have the same result.
Do you know if there is any limitations with the Esri server versions and Esri JS API 4.x?
I tried the same token with 3.x and works fine. I am attaching an image with the object in 4.x that shows that the token is there.
Thank you very much!
Cesar,
If that is not working then this sounds like a bug that needs to be reported to esri tech support. There is no version limitation that I am aware of.
Robert,
I was afraid of it. Thank you very much for your help!
Kind regards