I have a secured a secured service that you either try to print or export it fails to export the secured layers. Print and export map don't appear to include the token. If you manually add the token to each layer that works. I'm using a built in user via a simple login with username and password. Is this a bug?
version arcgis==2.0.1
code sample (with workaround)
gis = GIS(portal_url, username=portal_username, password=portal_password)
wm_item = gis.content.get('ITEMID')
wm = WebMap(wm_item)
e = polygon.extent
ext = {'spatialReference': {'latestWkid': 3857, 'wkid': 102100},
"xmin": 14219202.665619811,
"ymin": -3017623.8659692756,
"xmax": 14225164.753826046,
"ymax": -3005929.0006416594}
# DW another esri bug? Doesn't add the token on print or export
for layer in wm.layers:
layer.token = gis._con.token
map_options = {
"extent": ext
}
# compose combined JSON
print_options = {
"mapOptions": map_options,
"operationalLayers": wm._webmapdict["operationalLayers"],
"baseMap": wm._basemap,
"exportOptions": {"dpi": 96},
"layoutOptions": layoutOptions
}
printed_file_url = wm.print(file_format='JPG', layout_template="A4 Landscape",
extent=ext, layout_options=layoutOptions)