Hi Tanu,
Thank you for writing back to me, i explored few options as suggested in the above links.
These things did not work for me.
1. ImportCredentials into the GP-- even if this would have worked i do not prefer embedding credentials into the GP.
and i had difficulty in creating an .ags file with saved password inside pro. In order to do this, i had to use ArcMap...which again is a workflow i prefer not to use any more.
2. The python code provided in Web map printing with arcpy.mp—ArcPy | ArcGIS Desktop did not honor dynamic parameters in the layout.
Here is what i ended up doing.
1. Made a copy of the Export Web Map python.
2. Wrote a method to generate token from the portal.
3. Manipulated the webmap json which comes as input.
#######################
token = generateToken(username,password,portalUrl)
webMapJson = json.loads(WebMap_as_JSON)
for op in webMapJson["operationalLayers"]:
op["token"] = token
result = arcpy.mp.ConvertWebMapToArcGISProject(json.dumps(webMapJson), layoutTemplate)
##################
4. Followed the instructions in Share a print service web tool with custom layouts from ArcGIS Pro—Documentation (10.7) | ArcGIS Ent...
5. And published the modified Export Web Map python as a geoprocessing tool
and it seemed to work for me....
So, until there is an OOB way to do this within the Web App Builder or changes in the Export Web Map tool supplied with the ArcGIS Pro, i do not see a way to print secured service or you may suggest an alternative
Sandeep