Hey all,
I am trying to write a script to automate the publishing of web layers and have run into a problem since our organization uses an SSO (Single Sign On). I wrote script to get the SSO token, and login to portal (Below, with all appropriate packages imported).
# Gettoken for the Palm Beach County SSO
def getToken(portal, sso):
print('Connecting to portal...\n')
# Get username and password
username = input(str('Enter your SIM username and press Enter: '))
# warnings.simplefilter("ignore", category=getpass.GetPassWarning)
password = getpass.getpass('Enter your SIM password and press Enter: ')
payload = {
"username": username,
"password": password,
"client": "referer",
"referer": portal,
"expiration": "1440",
"f": "json"
}
response = requests.post(sso, data=payload)
token = response.json().get("access_token")
return token
#Sign into portal
def portalConnect():
portal_url = 'myPortalurl' #my script has the actual urls for portal and sso here
sso_url = 'mySSOurl'
token = getToken(portal_url, sso_url)
gis = GIS(portal_url, token=token)
print('\nConnected to: ', gis.properties.name)
The above code results with:
Connecting to portal...
Connected to: Palm Beach County ArcGIS Enterprise
However, when I actually try to exportTOSDDraft I get
ValueError: Unable to connect to portal.
I tried using the arcpy.SignInToPortal and it says 'unable to generate token' but "token" is not a valid parameter for this function.
Has anyone been successful in publishing a service definition draft to portal when there is an SSO? Or does anyone know how I can do this?
Thanks.