CORS error after identifymanager registertoken

177
2
01-05-2022 02:31 AM
ADITYAKUMAR1
Occasional Contributor II

Hi ,

 I am  trying to consume a map service url with token using Idenntifymanager. Below is the code I am using.

var tokenValue = "xxxxx";
IdentityManager.registerToken({
server: "https://mydomina.com/arcgis/rest/services",
token: tokenValue
});
var layerUrl = "https://mydomain/arcgis/rest/services/map/MapServer";
var layer = new ArcGISDynamicMapServiceLayer(layerUrl);
map.addLayer(layer);

 

After doing so I can see the layer in the content panel but on the map its not showing. I am getting the below error.

ADITYAKUMAR1_0-1641378500753.png

If I remove the identifymanager its working fine.But in order to fetch the data from federated portal I need to pass a token. And while doing so, I am getting the above error. Any one else had the same problem?

I have added  esriConfig.defaults.io.corsEnabledServers.push("ourserver.com")but this didnt helped.

 

Thanks

Aditya Kumar

0 Kudos
2 Replies
Noah-Sager
Esri Regular Contributor

My hunch is that IdentityManager requires POST requests via https. Since the app is being run over http to localhost, this is being prevented.

https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManager.html

Can you try hosting the app somewhere over https?

0 Kudos
ADITYAKUMAR1
Occasional Contributor II

@Noah-Sager  Thanks for responding. I tried hosting my solution in the DNS. But problem remains same even after converting http to https.

0 Kudos