I am trying to add a simple layer of security to my ArcGIS JS app. I do not want to prompt my users for a login to retrieve a token. So instead I pass the username/password inside this PHP proxy: https://github.com/Esri/resource-proxy/tree/master/PHP

This works great for all of my needs EXCEPT when I try to execute the PrintTask. I get a CORS error because the proxy is not getting prepended to the layer URLs inside the "Web Map as JSON" string.

web map as json string

I basically have my AMD javascript set up as follows:

//in init.js
defne(["dojo/ready", "esri/urlUtils", "esri/tasks/PrintTask", "app/myConfig"], function(ready, urlUtils, PrintTask, config){
        urlPrefix: "myMachine.org"
        proxyUrl: "myMachine.org/proxy/"

    printTask = new PrintTask(config.helperServices.printUrl); //global

//in print.js
//do all my AMD loading stuff...
//within my printLayout: do stuff

var params = new PrintParameters();
params.map = map;
printTask.execute(params, function(){...}

I receive the following error if firebug: enter image description here

I suppose it is breaking because my async scope/structure. When I prepend the proxy to the urls in REST GP processing task it prints as expected.

Can anyone think of a workaround that would allow me to use the same logic of using this simple proxy.php to pass security credentials that also prepends my proxy to my web map as json url?

  • We have this problem with a secure service. I have the .NET proxy set to run token auth for the service. URLs to the service in the Web_Map_as_JSON cause the PrintTask execute to fail 400, citing the service URLs that are secured. We have short lived tokens and the way this article reads we shouldn't need a custom print service. I've tried proxying the execute call to fetch a token and changing the URLs in the Web_Map_as_JSON to go through the proxy but no dice. Is it possible to use PrintTask with a webmap definition referencing secure services by somehow using the resource proxy or do we nee – user68014 Feb 25 '16 at 16:36
  • Please ask this as a question, rather than "answer" on an existing question. You may want to review the Tour. – mkennedy Feb 25 '16 at 17:32
  • If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. - From Review – Kersten Feb 25 '16 at 17:37

have you taken a look at this article?

Printing maps that contain secured services http://resources.arcgis.com/en/help/main/10.2/#/Printing_maps_that_contain_secured_services/0154000005q3000000/

in general, its not sufficient to try and supply proxied urls in the WebmapJSON because the PrintService is ultimately going to have to make its own entirely seperate (and I believe SOAPy) calls to grab the data and create its output.

If i'm off base and you've already set up a dedicated 'SecurePrinting' service, please let me know.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.