How To: Publish a custom print service with embedded credentials from ArcGIS Pro to a standalone ArcGIS Server site
Summary
The instructions below describe how modify the Export Web Map task with embedded credentials, and publish it as a custom print geoprocessing service from ArcGIS Pro to a standalone ArcGIS Server site.
Procedure
- Modify the Export Web Map task.
- Locate the Export Web Map Python tool in ArcGIS Pro. Navigate to Geoprocessing > Toolboxes > Server Tools > Printing.
- Right-click Export Web Map and select Edit to open the script file.
- Copy and paste the script into a new text editor, for example, Notepad. Edit the script to include the ImportCredentials and ClearCredentials functions to match the following script. The following example is a script that takes the state of a web map in a web application (for example, included services, layer visibility settings, and client-side graphics) and returns a printable page layout or basic map of the specified area of interest in the vector (such as pdf, svg, etc.) or image (such as png, jpeg, etc.).
# Import required modules # import sys import os import arcpy import uuid # constants # SERVER_PROD_NAME = 'Server' PRO_PROD_NAME = 'ArcGIS Pro' PAGEX_FILE_EXT = 'pagx' MAP_ONLY = 'map_only' # Specify credentials for secured services in the WebMap JSON secure_server_connections = [r'C:\Users\<username>\server on <connection file name>.ags'] # Import credentials importedConnections = arcpy.ImportCredentials(secure_server_connections) # default location and current product name # _defTmpltFolder = os.path.join (arcpy.GetInstallInfo()['InstallDir'], r"Resources\ArcToolBox\Templates\ExportWebMapTemplates") _prodName = arcpy.GetInstallInfo()['ProductName'] _isMapOnly = False # export only map without any layout elements # def exportMap(result, outfile, outFormat): # Set output parameter # arcpy.SetParameterAsText(1, outfilename) # Clear credentials arcpy.ClearCredentials(importedConnections) if __name__ == "__main__": main()
- Save the file as a .py file and name the file as ExportWebMapSecured.py.
- In ArcGIS Pro, add the script to a toolbox. Refer to ArcGIS Pro: Add a script tool for more information. In the Parameters tab, match the parameters from the Export Web Map Python tool as shown in the following images.


- Run the script tool in ArcGIS Pro.
Note: Ensure to fill-out the Layout Template field.

The following is a WebMap as JSON example:
{"mapOptions":{"showAttribution":true,"extent":{"xmin":-37570328.14272009,"ymin":-15552387.679177042,"xmax":37570328.14272009,"ymax":19552387.679177042,"spatialReference":{"wkt":"PROJCS[\"WGS_1984_Web_Mercator_Auxiliary_Sphere\",GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Mercator_Auxiliary_Sphere\"],PARAMETER[\"False_Easting\",0.0],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",0],PARAMETER[\"Standard_Parallel_1\",0.0],PARAMETER[\"Auxiliary_Sphere_Type\",0.0],UNIT[\"Meter\",1.0]]"}},"spatialReference":{"wkt":"PROJCS[\"WGS_1984_Web_Mercator_Auxiliary_Sphere\",GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Mercator_Auxiliary_Sphere\"],PARAMETER[\"False_Easting\",0.0],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",0],PARAMETER[\"Standard_Parallel_1\",0.0],PARAMETER[\"Auxiliary_Sphere_Type\",0.0],UNIT[\"Meter\",1.0]]"},"scale":147914381.897889},"operationalLayers":[{"id":"defaultBasemap","title":"World Topographic Map","opacity":1,"minScale":0,"maxScale":0,"url":"https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"}],"exportOptions":{"outputSize":[670,500],"dpi":96},"layoutOptions":{"titleText":"","authorText":"","copyrightText":"","customTextElements":[{"Date":"12/9/2019, 9:17:04 AM"}],"scaleBarOptions":{"metricUnit":"esriKilometers","metricLabel":"km","nonMetricUnit":"esriMiles","nonMetricLabel":"mi"},"legendOptions":{"operationalLayers":[]}}}
- Connect to the ArcGIS Server site and change the connection type to Administrator Connection to publish the geoprocessing service.

- Publish the successful result as a geoprocessing service.

- Test the published geoprocessing service by replacing the URL with the IWA-secured URL from the in-house server site in the Web Map as JSON example.
Related Information
- ArcGIS Server: Print maps that contain secured services
- ArcGIS Pro: Print maps that contain non-token based secured services from ArcGIS Server
- ArcGIS Pro: ConvertWebMapToArcGISProject
Last Published: 1/19/2023
Article ID: 000026010
Software: ArcGIS Pro 2.9.6, 2.9.5, 2.9.4, 2.9.3, 2.9.2, 2.9.1, 2.9, 2.8.8, 2.8.7, 2.8.6, 2.8.5, 2.8.4, 2.8.3, 2.8.2, 2.8.1, 2.8, 2.7.7, 2.7.6, 2.7.5, 2.7.4, 2.7.3, 2.7.2, 2.7.1, 2.7, 2.4.3, 2.4.2, 2.4.1, 2.4, 2.3.3, 2.3.2, 2.3.1, 2.3, 2.2.4, 2.2.3, 2.2.2, 2.2.1, 2.2, 2.1.3, 2.1.2, 2.1.1, 2.1, 2.0.1, 2.0 ArcGIS Server 10.9.1, 10.9, 10.8.1, 10.8, 10.7.1, 10.7, 10.6.1, 10.6