Select to view content in your preferred language

Switch active portal with arcpy

1351
1
09-18-2023 11:31 AM
Status: Open
Labels (1)
GT_UTCO
Emerging Contributor

Currently there is no way to switch active portals in using ArcPy from what I can see in the current functions:

GT_UTCO_0-1695058378369.png

The workaround would be to us the SignInToPortal function, but this requires providing a username and password. This is not ideal since that information has to be stored somehow. It also seems unnecessary since once a user is signed into a portal in ArcGIS Pro, it will keep the connection for a long time even if the user switches to another portal. The user can then manually switch around to different portals without having to sign-in again. Of course every so often the user has to re-authenticate with the portal account manually in Pro. 

This becomes more powerful since in the arcgis api it is possible to connect to portal via Pro but it is dependent on the currently active portal. It even works when Pro isn't open. So there is potential to run scripts without having to store usernames and passwords for portal functions. Of course there is the trade-off of having to manage the portal sign-ins have a good status. 

Tags (3)
1 Comment
AmyRoust

To add to this excellent idea, the workaround that GT_UTCO offers does not work for users who use IWA to authenticate. I cannot use the SignInToPortal function to force a switch of portals because storing the username and password in the script does not work for IWA (using Active Directory credentials to log in). At this point, my only workaround is to use a Notebook for my all-ArcGIS Online script and leave my portal default on our Enterprise Portal for our other scripts. This breaks our organization's governance guidelines because we don't allow individuals to own maintenance scripts so that scripts stop working when a person leaves the company.