SignInToPortal

Summary

Allows you to sign in to a portal.

Discussion

To share content or run Ready To Use Tools, you must be signed in to a portal. The portal can be either an ArcGIS Enterprise portal or an ArcGIS Online portal.

To add a portal connection, click the Project tab on the ribbon and click the Portals page. For more information, see Manage portal connections from ArcGIS Pro.

SignInToPortal will add the portal URL to your portal connections (if necessary), sign in, and set the portal to active. If executed in the Python window, the portal will be set as the active portal (if different), and added to the portal connections for future ArcGIS Pro or stand-alone Python sessions. However, if executed in a stand-alone Python session, the portal information will be used only for the duration of the active Python session.

When signing in as portal users or in to accounts based on the following supported portal authentication configurations, different parameters may be required:

  • If the portal uses built-in security, provide a username and password.
  • If the portal uses public key infrastructure (PKI) authentication, provide a PKCS12 formatted certificate file (.pfx or .p12) and certificate password.

    You can also provide a PEM formatted certificate and key file. Both the certificate and the key have a .pem file extension.

  • If the portal uses Integrated Windows Authentication (IWA), leave the username and password parameters empty. Providing a Windows username and password is not supported.

Signing in to a portal that uses IWA or PKI is not supported on a Linux machine.

Syntax

SignInToPortal (portal_url, {username}, {password}, {cert_file}, {key_file})
ParameterExplanationData Type
portal_url

The URL of the portal to sign in to.

String
username

The user name of the user signing in to the portal. If the portal uses IWA, leave this parameter empty. You can only sign in as the current Windows user.

String
password

The password of the user signing in to the portal. If the portal uses PKI authentication, the password to the PKCS12 certificate file. If the portal uses IWA, leave this parameter empty.

String
cert_file

If the portal uses PKI authentication, the path to the PKCS12 formatted certificate file (.pfx or .p12) or the PEM formatted certificate file (.pem).

String
key_file

If the portal uses PKI authentication, the path to the PEM formatted key file (.pem).

String
Return Value
Data TypeExplanation
Dictionary

A dictionary of key value pairs for expires, referer, and token.

Code sample

SignInToPortal example 1

Sign in to a portal that uses built-in security.

import arcpy

arcpy.SignInToPortal("https://webadaptorhost.domain.com/webadaptorname", 
                     'username', 'password')
SignInToPortal example 2

Sign in to a portal that uses public key infrastructure (PKI authentication) using a PKCS12 formatted certificate file (.pfx or .p12) and password.

import arcpy

arcpy.SignInToPortal("https://webadaptorhost.domain.com/webadaptorname", 
                     cert_file="C:\\path\\to\\mycert.pfx", 
                     password="cert.password")
SignInToPortal example 3

Sign in to a portal that uses public key infrastructure (PKI authentication) using a PEM formatted certificate file (.pem) and key file (.pem).

import arcpy

arcpy.SignInToPortal("https://webadaptorhost.domain.com/webadaptorname", 
                     cert_file="C:\\path\\to\\mycert.pem", 
                     key_file="C:\\path\\to\\mykey.pem")
SignInToPortal example 4

Sign in to a portal that uses Integrated Windows Authentication (IWA) by omitting the username and password.

import arcpy

arcpy.SignInToPortal("https://webadaptorhost.domain.com/webadaptorname")

Related topics