Select to view content in your preferred language

Switch active portal with arcpy

1923
2
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)
2 Comments
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.

DougBrowning

Anyone ever figure this out?  

I see here https://developers.arcgis.com/python/latest/guide/working-with-different-authentication-schemes/ that using
gis = GIS("pro")
is only the active portal but no way to switch that I can find.

We have two diff AGOLs organizations and 12 different portals now.  So as an admin we often move data around but right here we get stuck.  We had used FeatureLayer in the past but we are seeing now that on long query's the token is getting left off the call so we are stuck now.

Just like the other poster its all SAML logins so no un or pass even exist (not that I would ever hardcode a password).

Thanks for any ideas.


I would think it would be an easy add.