In [1]:
"""

   Common Login Methods

"""
import arcrest
username = "SomeUserName"
password = "SomePassword"
org_url = "https://chronus.esri.com/portal"

In [2]:
"""
BUILT-IN security is AGOL, Portal and Servers default login method.  
This is just a simple username/password use case that returns a token
"""

#AGOL Login
sh = arcrest.AGOLTokenSecurityHandler(username=username, 
                                      password=password)

#Portal Login
sh = arcrest.PortalTokenSecurityHandler(username=username, 
                                        password=password, 
                                        org_url=org_url)

#ArcGIS Server Login
sh = arcrest.AGSTokenSecurityHandler(username=username,
                                    password=password,
                                    org_url="https://chronus.esri.com/arcgis")

In [ ]:
"""
You can secure access to your server/portal using Lightweight Directory Access Protocol (LDAP). 
When you use LDAP, logins are managed through your organization's LDAP server.
"""

#LDAP Login
sh = arcrest.LDAPSecurityHandler(org_url=org_url, 
                                 username="AVWORLD\\testaccount", 
                                 password=password)

"""
Using ArcGIS Desktop (SAML work around)
"""
sh = arcrest.ArcGISTokenSecurityHandler()

"""
PKI - A public key infrastructure (PKI) is a set of roles, policies, and procedures needed to create, manage, 
distribute, use, store, and revoke digital certificates and manage public-key encryption
"""
sh = arcrest.PKISecurityHandler(org_url=org_url, 
                                keyfile=r"<keyfile path>", 
                                certificatefile=r"<cert file path>")