requests-arcgis-auth
requests-arcgis-auth copied to clipboard
Consider adding a helper function to determine the site security posture (derive user name, prompt for pwd)
The ArcGISServerAuth object supports a username/password as optional parameters... Only need to be supplied if the site is token authentication.
Could query the site "/arcgis/rest/info" to determine if its is Token Authentication. And if so,
Then derive the logged in user (down-level logon name format) and prompt for a password.
EX:
import requests
import os
import getpass
s = requests.session()
if <IS TOKEN AUTHENTICATION>:
down_level_logon_name = r"{}\{}".format(os.getenv("userdomain"), getpass.getuser())
pwd = getpass.getpass("Enter password for {}: ".format(down_level_logon_name))
s.auth = ArcGISServerAuth(down_level_logon_name, pwd)
else:
s.auth = ArcGISServerAuth()