Select to view content in your preferred language

ArcPy SignInToPortal Doesn't Handle SAML Logins But ArcGIS Pro SDK ArcGISPortal Class Does

155
1
12-04-2024 03:00 PM
JoshuaBixby
MVP Esteemed Contributor

This question is primarily for Esri staff.  I am interested in understanding why the ArcPy ArcGIS Online/Portal functions are so limited compared to the ArcGISPortal and ArcGISPortalManager classes in the ArcGIS Pro SDK.  I assume both ArcPy and ArcGIS Pro SDK are hooking into the same underlying compiled code, so I know more can be done with ArcPy since I can do it with Pro SDK in Python using GitHub - pythonnet/pythonnet: Python for .NET .

One specific issue is how SignInToPortal—ArcGIS Pro | Documentation either doesn't work or doesn't work correctly with SAML logins.  It is not uncommon in my organization to have users with lots of Portals registered in ArcGIS Pro, many of which are SAML-based logins.  When using Pro SDK with GitHub - pythonnet/pythonnet: Python for .NET , a script, script tool, or notebook can simply loop through the Portals and make sure the user is signed into each portal.  If the user isn't signed in, a window pops up for them to finish the SAML login process for a given site.

 

 

import pythonnet
pythonnet.load("coreclr")

import clr
clr.AddReference("ArcGIS.Desktop.Core")

from ArcGIS.Desktop.Core import ArcGISPortalManager
portal_manager = ArcGISPortalManager.Current
for portal in portal_manager.GetPortals():
    portal.SignIn()

 

 

 That's it, 3 lines of functional code and some import statement.

The native ArcPy equivalent is impossible because SignInToPortal—ArcGIS Pro | Documentation chokes on handling the sign in for SAML logins.  Even if the function worked, it forces a change to the active portal, which isn't always desirable, so then you have to go back and reset the active portal.

0 Kudos
1 Reply
AndresCastillo
MVP Alum

@JoshuaBixby ,

great find.

 

@JonahLay 

I see this ArcGIS Pro idea is closed.

Based on Joshua's finding's above, is there a chance the idea can be reopened?

 

@TedCronin 

I see you have a need for this here:
https://community.esri.com/t5/arcgis-api-for-python-questions/pass-ad-login-from-arcgis-to-arcpy/td-...

 

tagging my comment here for other reference with this saml login issue:

https://community.esri.com/t5/arcgis-enterprise-questions/unable-to-generate-tokens-using-saml-enter...

 

0 Kudos