Can I use an Enterprise account of ArcGIS Online with the ArcGIS API? If so, can you show me an example?

1855
3
03-29-2017 09:50 AM
JeffZurakowski
New Contributor II

When I use this example below with an AGO Enterprise account, I get an error.  I can get this to work with an ArcGIS Online account, but we have our organization setup to use enterprise accounts.  Thanks for the help!

from arcgis.gis import GIS
from IPython.display import display

gis = GIS("https://www.arcgis.com", "arcgis_python", "P@ssword123")

RuntimeError: Unable to generate token.
Invalid username or password.
(Error Code: 400)

0 Kudos
3 Replies
MatthiasSchenker
Esri Contributor

Hi Jeff

Have a loog at the help on working with different authentication schemes | ArcGIS for Developers  for the different login options. This worked in my case.

It could be that you are set up so you just need to enter the url to your subscription 

gis = GIS("https://xxx.maps.arcgis.com")

and have Integrated Windows Authentication using NTLM or Kerberos (this works in my case) or you can for example use 

gis = GIS("pro")

to use the login from your current ArcGIS Pro session.

From the website referenced above:

Using the pro authentication scheme, scripts can get an instance of the GIS class representing the active portal in ArcGIS Pro without requiring the user to pass their credentials in a second time. In this mode, users can leverage the Pro app to login to the portal and their scripts can use whichever Portal is currently active. This mode can also serve as a bridge for users with advanced authentication scenarios like IWA using NTLM or Kerberos or Smart Card where signing in with credentials may not be possible or desirable.

0 Kudos
JeffZurakowski
New Contributor II

Thanks for the help Matthias.  I have tried the https://xxx.maps.arcgis.com but this is what returns the below error.  I added my enterprise credentials to this example.  If I use my ArcGIS login, it works.  We have a mix of enterprise logins and arcgis online logins in our subscription.  

RuntimeError: Unable to generate token.
Invalid username or password.
(Error Code: 400)

0 Kudos
JeffZurakowski
New Contributor II

I had a call back from ESRI tech support.  Using Enterprise Logins of ArcGIS Online is not supported with the current ArcGIS API for Python.  It does work with Pro like Matthias suggested above.  From ESRI:

ENH-000103131 Provide support for logging into ArcGIS Online using enterprise logins directly from the ArcGIS API for Python.