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().
Problem 1:
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.
Problem 2:
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.
Problem 3:
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.