AnsweredAssumed Answered

Javascript API Note getting token wit proxy.

Question asked by cadgis on Feb 21, 2018
Latest reply on Feb 21, 2018 by cadgis

I have configured  proxy and trying to consume a secured layer through proxy in Arcgis javascript.

When I test  the proxy manually i get the response  in web browser. That is to to say,  when I enter the following Url in the broweser it returns a valid token :-

 

Token:

QBh62mCJxxyyXXyyCCCVVOdfDopSvrUX_4qq7IcMcpz2-U

  URL :

http://localhost/DotNet/proxy.ashx?http://00.00.00:6080/arcgis/tokens?request=gettoken&username=user&password=123&

 

But through Javascript , gives an error :

 dojo.io.script error Error: Token Required

Javascript :

 esriConfig.defaults.io.proxyUrl = "http://localhost/DotNet/proxy.ashx";
esri.config.defaults.io.alwaysUseProxy = false;

urlSecuredlayer = "http://00.00.00.00:6080/arcgis/rest/services/myQuery/mylayer/MapServer/0";
Securedlayer = new esri.layers.FeatureLayer(urlSecuredlayer, { id: "urlSecuredlayer", mode: esri.layers.FeatureLayer.MODE_ONDEMAND, outFields: ["*"] });

    tiledLayer1 = new ArcGISTiledMapServiceLayer(urlsatellite, { id: "SatelitteMap" });
    app.map.addLayer(tiledLayer1);

    var states_Symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, 
                   new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,  
                   new dojo.Color([255, 32, 255, 0.35]), 1), 
                   new dojo.Color([255, 65, 125, 0.35]));

    urlSecuredlayer.setRenderer(new esri.renderer.SimpleRenderer(states_Symbol));
    app.map.addLayers([Securedlayer]);

 

Thank you for any help.

Outcomes