<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Printing Secured Service in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/printing-secured-service/m-p/115436#M10755</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I haven't seen a satisfactory answer to this issue but maybe somebody has some fresh ideas.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have some secured services hosted in Server 10.1 that use long term tokens. In order to facilitate printing I published a custom Export Web Map tool according to these instructions - &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/#/Printing_maps_that_contain_secured_services/0154000005q3000000/"&gt;Printing maps that contain secured services &lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I can successfully use this custom service to print map containing all unsecured layers but as soon as I add a layer from the secured service I get: {"error":{"code":400,"message":"Unable to complete operation.","details":["Error executing tool."]}}.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I paste all of the same parameters into the REST Service Directory interface I receive the same error, so I don't think it's a problem with the proxy page.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the content of the Web_Map_as_JSON parameter:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;{"mapOptions":{"showAttribution":true,"extent":{"xmin":-13074789.94993775,"ymin":4015647.8563408996,"xmax":-13073490.52045701,"ymax":4016726.33503677,"spatialReference":{"wkid":102100}},"spatialReference":{"wkid":102100}},"operationalLayers":[{"id":"layer0","title":"layer0","opacity":1,"minScale":591657527.591555,"maxScale":1128.497176,"url":"&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer" rel="nofollow" target="_blank"&gt;http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer&lt;/A&gt;&lt;SPAN&gt;"},{"id":"layer2","title":"layer2","opacity":1,"minScale":0,"maxScale":0,"url":"&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://ec2-54-243-148-157.compute-1.amazonaws.com/be/rest/services/v2/BERides/MapServer?token=MY_TOKEN_GOES_HERE" rel="nofollow" target="_blank"&gt;http://ec2-54-243-148-157.compute-1.amazonaws.com/be/rest/services/v2/BERides/MapServer?token=MY_TOKEN_GOES_HERE&lt;/A&gt;&lt;SPAN&gt;","visibleLayers":null,"layers":[]},{"id":"layer1","title":"layer1","opacity":1,"minScale":591657527.591555,"maxScale":1128.497176,"url":"&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://services.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places/MapServer" rel="nofollow" target="_blank"&gt;http://services.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places/MapServer&lt;/A&gt;&lt;SPAN&gt;"}],"exportOptions":{"outputSize":[800,1100],"dpi":96}}&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm using the same token to add the layers to the map and am having no display problems.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Not sure what to troubleshoot next. Any ideas?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 12 Feb 2013 20:18:46 GMT</pubDate>
    <dc:creator>JillianStanford</dc:creator>
    <dc:date>2013-02-12T20:18:46Z</dc:date>
    <item>
      <title>Printing Secured Service</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/printing-secured-service/m-p/115436#M10755</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I haven't seen a satisfactory answer to this issue but maybe somebody has some fresh ideas.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have some secured services hosted in Server 10.1 that use long term tokens. In order to facilitate printing I published a custom Export Web Map tool according to these instructions - &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/#/Printing_maps_that_contain_secured_services/0154000005q3000000/"&gt;Printing maps that contain secured services &lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I can successfully use this custom service to print map containing all unsecured layers but as soon as I add a layer from the secured service I get: {"error":{"code":400,"message":"Unable to complete operation.","details":["Error executing tool."]}}.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I paste all of the same parameters into the REST Service Directory interface I receive the same error, so I don't think it's a problem with the proxy page.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the content of the Web_Map_as_JSON parameter:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;{"mapOptions":{"showAttribution":true,"extent":{"xmin":-13074789.94993775,"ymin":4015647.8563408996,"xmax":-13073490.52045701,"ymax":4016726.33503677,"spatialReference":{"wkid":102100}},"spatialReference":{"wkid":102100}},"operationalLayers":[{"id":"layer0","title":"layer0","opacity":1,"minScale":591657527.591555,"maxScale":1128.497176,"url":"&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer" rel="nofollow" target="_blank"&gt;http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer&lt;/A&gt;&lt;SPAN&gt;"},{"id":"layer2","title":"layer2","opacity":1,"minScale":0,"maxScale":0,"url":"&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://ec2-54-243-148-157.compute-1.amazonaws.com/be/rest/services/v2/BERides/MapServer?token=MY_TOKEN_GOES_HERE" rel="nofollow" target="_blank"&gt;http://ec2-54-243-148-157.compute-1.amazonaws.com/be/rest/services/v2/BERides/MapServer?token=MY_TOKEN_GOES_HERE&lt;/A&gt;&lt;SPAN&gt;","visibleLayers":null,"layers":[]},{"id":"layer1","title":"layer1","opacity":1,"minScale":591657527.591555,"maxScale":1128.497176,"url":"&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://services.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places/MapServer" rel="nofollow" target="_blank"&gt;http://services.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places/MapServer&lt;/A&gt;&lt;SPAN&gt;"}],"exportOptions":{"outputSize":[800,1100],"dpi":96}}&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm using the same token to add the layers to the map and am having no display problems.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Not sure what to troubleshoot next. Any ideas?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Feb 2013 20:18:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/printing-secured-service/m-p/115436#M10755</guid>
      <dc:creator>JillianStanford</dc:creator>
      <dc:date>2013-02-12T20:18:46Z</dc:date>
    </item>
    <item>
      <title>Re: Printing Secured Service</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/printing-secured-service/m-p/115437#M10756</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am experiencing the same issue described here.&amp;nbsp; Has a solution been supplied?&amp;nbsp; Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Jul 2013 20:16:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/printing-secured-service/m-p/115437#M10756</guid>
      <dc:creator>ChetEgbert</dc:creator>
      <dc:date>2013-07-03T20:16:54Z</dc:date>
    </item>
    <item>
      <title>Re: Printing Secured Service</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/printing-secured-service/m-p/115438#M10757</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I tackled this issue earlier and hope my solution applies here. The source of the issue is the long-term token. When you add the layer to the map like so:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;map.addLayer(new esri.layers.ArcGISDynamicMapServiceLayer("http://ec2-54-243-148-157.compute-1.amazonaws.com/be/rest/services/v2/BERides/MapServer?token=MY_TOKEN_GOES_HERE"));&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;the token is passed in the URL. BUT, that token is only good from the referral URL. You'll see that the token is in the URL in the webmap_as_json request. The server that the printservice is on can not access that url with that token because it is not that 'referrer'.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What I did was strip the token from the webmap_as_json before it goes to the server. There may be a more elegant way, and I'm open to improvements.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
//This goes in the original map initialization function
esri.setRequestPreCallback(function (e) {
&amp;nbsp; if (e.content &amp;amp;&amp;amp; e.content.Web_Map_as_JSON) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; e.content.Web_Map_as_JSON = e.content.Web_Map_as_JSON.replace(/\?token\=MY_TOKEN_GOES_HERE/g, "")
&amp;nbsp; }
&amp;nbsp; return e;
});
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 06:48:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/printing-secured-service/m-p/115438#M10757</guid>
      <dc:creator>MattLane</dc:creator>
      <dc:date>2021-12-11T06:48:32Z</dc:date>
    </item>
    <item>
      <title>Re: Printing Secured Service</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/printing-secured-service/m-p/115439#M10758</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Oh, and if you try that code, make sure you escape any special characters in your token with a \. &lt;/SPAN&gt;&lt;A href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions"&gt;Regular expressions&lt;/A&gt;&lt;SPAN&gt; information.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jul 2013 13:31:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/printing-secured-service/m-p/115439#M10758</guid>
      <dc:creator>MattLane</dc:creator>
      <dc:date>2013-07-05T13:31:09Z</dc:date>
    </item>
    <item>
      <title>Re: Printing Secured Service</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/printing-secured-service/m-p/1225145#M79113</link>
      <description>&lt;P&gt;Are you using enterprise or just ArcGIS server to do your user management? Depends on which one there, there is a generateToken service that you can use to create a short-term token.&lt;/P&gt;&lt;P&gt;Use a POST request and use the referral to create a token for the specific secure service that requires it.&lt;/P&gt;&lt;P&gt;Than in your operational layer definition, add a &amp;lt;token&amp;gt; parameter with the generate token as it's value.&lt;BR /&gt;&lt;BR /&gt;You can find the specific JSON format how of to incorporate tokens into the operationalLayer in the ExportWebMap specification—ArcGIS Server&lt;BR /&gt;&lt;A href="https://enterprise.arcgis.com/en/server/latest/publish-services/windows/exportwebmap-specification.htm" target="_blank"&gt;https://enterprise.arcgis.com/en/server/latest/publish-services/windows/exportwebmap-specification.htm&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2022 12:47:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/printing-secured-service/m-p/1225145#M79113</guid>
      <dc:creator>gpei_ahuang</dc:creator>
      <dc:date>2022-10-25T12:47:17Z</dc:date>
    </item>
  </channel>
</rss>

