Problem: Unable to log in to ArcGIS Online using ArcPy
Attempting to log in to ArcGIS Online using ArcPy sometimes fails, and returns the following warning message:
Warning: 001561: ArcGIS Online/Portal authorization requires direct sign in
The following shows a sample failed script:
import arcpy userName = "user1" passWord = "password1" # For ArcMap arcpy.SignInToPortal_server(userName, passWord, "http://www.arcgis.com/") # For ArcGIS Pro arcpy.SignInToPortal(arcpy.GetActivePortalURL(), 'username', 'password') print arcpy.GetMessages()
There are two possible causes:
- The Sign In To Portal tool ignores input values for the portal_url parameter, and reads the URL set in ArcGIS Administrator. If the portal URL is absent in ArcGIS Administrator, the warning message is returned, and login to ArcGIS Online fails. Refer to ArcMap: Sign In To Portal for more information.
- The Sign In To Portal tool is executed using a stand-alone script. This function is not supported and is a known limitation.
Solution or Workaround
Add the portal_url value in ArcGIS Administrator.
- Open ArcGIS Administrator.
- Select the node of the machine, and click Advanced to open the Advanced Configuration window.
- Click Manage Portal Connections to open the Manage Portal for ArcGIS Connections window.
- Click Add. Insert http://www.arcgis.com/ and click OK.
- Click Connect.
- Click Save > Ok.
After adding the portal_URL parameter in ArcGIS Administrator, the syntax in the SignInToPortal tool for ArcMap is empty, as shown below.
arcpy.SignInToPortal_server(userName, passWord, "")
To run the code outside of ArcGIS Pro or ArcMap, the following conditions must be met:
- ArcGIS Pro or ArcMap is currently open.
- The Sign me in automatically option is enabled for ArcGIS Pro. Refer to ArcGIS Pro: Sign in to your organization for more information.
- ArcGIS Pro is authorized to work offline. Refer to ArcGIS Pro: Start ArcGIS Pro with a Named User license for more information.
- ArcGIS Pro: 001561: ArcGIS Online/Portal authorization requires direct sign in.
- ArcMap: Sign in to ArcGIS Online or ArcGIS Enterprise in ArcGIS Desktop applications