I need a way to code signing in and signing out of ArcGIS Online from a Python toolbox run within ArcGIS
Pro. The existing tool, arcpy.SignInToPortal() , is flaky. It appears there is no arcpy.SignOutOfPortal().
I have found that if I open ArcGIS Pro and do not sign in this is indicated in the upper right corner of the application as 'Not signed in'. If I run the Python arcpy.SignInToPortal() and provide portal URL, and good credentials then it appears I am signed in by the change in the text in the upper right corner of the application. Often times, however, I can not access authorized data. If I try to add a layer by hand from ArcGIS Online I am prompted to sign in even though the text in the upper right corner indicates that I already am signed in.
If ArcGIS Pro remembers me from a previous session when I start the program I get logged in as a specific user automatically. There are times, however, when I don't want to be logged in as that user. Lets say I, or one of my toolbox users, need to run a Python toolbox script to back data up from AGOL to our local server. This should run as a user that does not have write privilege to AGOL. I thought to place arcpy.SignInToPortal() at the top of my script and provide a user credential that does not have write permission. Although I get no error when running this command the user in the upper right corner of ArcGIS Pro does not change. It indicates I remain signed in as the user from the previous session.
There appears to be no arcpy.SignOutOfPortal() command. If there was I could use it before using arcpy.SignInToPortal() to assure the user automatically signed in is no longer current. Then if arcpy.SignInToPortal() worked I could be sure the current user is one of appropriately permitted to run a script to backup date from AGOL to our servers.
Are you using a shared server where ArcGIS Pro is installed? If possible, I would recommend installing ArcGIS Pro on the individual(s) workstation. You could then assign them an ArcGIS Pro license. As long as that named user has privileges to the feature services, they can execute tools (i.e. Feature Class to Feature Class) to backup the data locally.
I am currently having the exact similar problem as "Problem 1" above.
I can stay signed in when I enter my credentials by hand and check "Sign in Automatically". However, when I run my python script using arcpy.SignInToPortal(), it boots me. As in, the next time I try to open Pro, it asks for a sign again.
I think this is affecting my script as well, I'm trying to publish to AGOL using the FeatureSharingDraft class. My script is failing at StageService_server.
Anybody have any thoughts/advice?