Unable to log in to ArcGIS Online using ArcPy

Last Published: April 25, 2020


Attempting to log in to ArcGIS Online using ArcPy sometimes fails, and returns the following warning message:

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, "")

# 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.

  1. Open ArcGIS Administrator.
  2. Select the node of the machine, and click Advanced to open the Advanced Configuration window.
ArcGIS Administrator window
  1. Click Manage Portal Connections to open the Manage Portal for ArcGIS Connections window.
    1. Click Add. Insert and click OK.
Manage Portal for ArcGIS Connections window
  1. Click Connect.
  2. 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:

Article ID:000021927

  • ArcGIS Pro
  • ArcMap

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options