I created an ESRI Python toolbox and setup one of the parameters of the toolbox as an encrypted string as the parameter is a location for the end user to enter a password.
The problem I am encountering is getting that string un-encrypted from the parameter using the only method I have ever used parameters[0].valueAsText
and the only method I could find in the ESRI documentation. This method keeps the string encrypted. Subsequently, I encounter errors when trying to use this parameter in the rest of the script. I'm using ArcGIS Desktop 10.3
def getParameterInfo(self):
"""Define parameter definitions"""
param0 = arcpy.Parameter(displayName = 'AGOL Username',
name = 'AGOL Username',
datatype ='GPString',
parameterType ="Required",
direction ="Input")
param1 = arcpy.Parameter(displayName = 'AGOL Password',
name = 'AGOL Password',
datatype ='GPEncryptedString',
parameterType ="Required",
direction ="Input")
param2 = arcpy.Parameter(displayName = 'AGOL Group ID',
name = 'AGOL Group ID found in the URL, when viewing group in AGOL',
datatype ='GPString',
parameterType ="Required",
direction ="Input")
param3 = arcpy.Parameter(displayName = 'Output Folder',
name = 'OutPut Folder to Store Zipped Downloaded Feature Services',
datatype ='DEFolder',
parameterType ="Required",
direction ="Input")
params = [param0, param1, param2, param3]
return params
def isLicensed(self):
"""Set whether tool is licensed to execute."""
return True
def updateParameters(self, parameters):
"""Modify the values and properties of parameters before internal
validation is performed. This method is called whenever a parameter
has been changed."""
return
def updateMessages(self, parameters):
"""Modify the messages created by internal validation for each tool
parameter. This method is called after internal validation."""
return
def execute(self, parameters, messages):
"""The source code of the tool."""
import os #,tempfile, shutil
#import zipfile
import json #, re
#import uuid
import time #datetime,
import urllib,urllib2
#import sys
username = parameters[0].valueAsText
password = parameters[1].valueAsText
groupid = parameters[2].valueAsText
outputLocation = parameters[3].valueAsText