Select to view content in your preferred language

QueryTask using tokens

2753
3
10-25-2010 01:31 PM
RobertTaylor
New Contributor
Is it possible to use a token with a single layer url in Javascript API? More specifically, with esri.tasks.QueryTask()?

For example, if I have a token:

var token = 123456

and place it at the end of a single layer url:

dynamicLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://mywebsite/ArcGIS_AD/rest/services/AD_All/Map_Service/MapServer/1?token=" + token);

it does not work.

However, in cases such as esri.layers.ArcGISDynamicMapServiceLayer, I can work around it by using:

dynamicLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://mywebsite/ArcGIS_AD/rest/services/AD_All/Map_Service/MapServer/?token=" + token);
var visibleLayers = [1];
dynamicLayer.setVisibleLayers(visibleLayers);
map.addLayer(dynamicLayer);

This works great with esri.layers.ArcGISDynamicMapServiceLayer() and esri.tasks.FindTask(), but I'm unable to find a workaround for esri.tasks.QueryTask().
It appears that I have to use the single layer url for QueryTask, which seems to be a problem when using tokens (see first example):

esri.tasks.QueryTask("http://mywebsite/ArcGIS_AD/rest/services/AD_All/Map_Service/MapServer/1");

Does anyone know of a work around for esri.tasks.QueryTask() when using tokens?

Thank you!
0 Kudos
3 Replies
GeorgePan
Occasional Contributor
Did you maken it work?
0 Kudos
nicogis
MVP Frequent Contributor
You can set the proxy and then in proxy you decide what do you want do. If you set in client token you could set short-token (less security).
0 Kudos
GeorgePan
Occasional Contributor
Did you maken it work?


I resolved the issue. It works well now. 🙂
0 Kudos