We are currently using ArcGIS server (AGS) 10.7.1 and ArcGIS Online (AGO) in our organization. We have some custom vector basemaps hosted in AGO, and some secured feature service layers published from AGS. I created a custom print service in ArcGIS Pro 2.4.1 and published it to AGS as a geoprocessing service. I then added the REST URL to AGO as the default print service (Organization > Settings > Utility Services > Printing). When I try to print a web map in AGO, the vector basemap shows in the resulting PDF but not the secured feature service layers. The logs in AGS show the error:
Error executing tool. Export Web Map : Failed to create layer from service at https://<server>/<webadaptor>/rest/services/<folder>/<service name>/FeatureServer/0. Failed to execute (Export Web Map). Failed to execute (Export Web Map).
In communicating with Support, we have determined that it is probably a permissions issue with the custom print service. Even though I created the service in Pro and published it to Server using the admin connection, the credentials are not being passed from the print service to the secure feature service. I also have a custom print service created and published in ArcMap, but this service will not print the vector base maps (apparently this is new tech in the ArcGIS Pro print service).
This link explains that the ImportCredentials function can be used to embed the proper credentials in the Print service in ArcGIS Pro: Web map printing with arcpy.mp—ArcPy | ArcGIS Desktop
My problem is I am not quite familiar enough with creating a python script tool to do this. I've started with example 8 here: ConvertWebMapToArcGISProject—ArcPy | ArcGIS Desktop
But I cannot get this to work with a script tool in Pro. Any help or suggestions would be much appreciated. Bottom line is I'd like to be able to print web maps in AGO containing vector base maps and secure feature service layers.