Select to view content in your preferred language

Multifactor Auth in AGOL & the Python API

1957
3
09-30-2019 10:26 AM
GregMcNamee
Regular Contributor

Is there no way to create GIS object connecting to an ArcGIS Online org, using the credentials of a user that has multi-factor authentication enabled? Our org requires administrators to use multi-factor authentication, but I can't find a way to log in to the org via the Python API. I keep getting this error:

If there's not a way to do it, is there a plan to add a mechanism to do so?

Greg McNamee
3 Replies
JeroenBaltussen1
Occasional Contributor

Hoi,

This issues is also very relevant for our organisation.

Do you maybe have an update for this item.

Jeroen Baltussen

Jonathan_Goergen
Occasional Contributor

I cannot run scripts to AGOL and I suspect MFA is the issue.  Are there ways to utilize scripts with MFA implemented?  I use to use scripts like below to access REST services, and generate tokens for the irritating "Token Required" message at REST endpoints for services I published while I am online:

Jonathan_Goergen_0-1714668766937.png

 

params = {'f': 'pjson', 'username': userName, 'password': pw, 'referer': 'https://www.arcgis.com', 'expiration': 21600}
tokenURL = 'https://www.arcgis.com/sharing/rest/generateToken'
response = requests.post(tokenURL, data = params, verify = False)
token = response.json()['token']

BenCapell_NWTF10
Occasional Contributor

I also need access to AGOL items via the ArcGIS API for Python while MFA is enabled on my account. Has there been any movement on this issue?

@HenryLindemann Do you have any recommendations? I saw you were able to answer a different authenication issue here.

Update:

The code below will provide access to items in the GIS (assuming the key was configured with access to the items). However, the lyr.manager.truncate() function errors while MFA is enabled. The function works successfully when MFA is not enabled.

url = 'yourorg.arcgis.com'
apikey = 'apikey-fromA AGOL'
gis = arcgis.gis.GIS(url, api_key=apikey)