Cannot establish credentialed connection using `GIS(url, username, password)`

12-01-2023 11:41 AM
New Contributor

Hello! I am trying to connect to my organization's AGOL as a first step in creating a script. But I cannot get paste stage one.

I am using the Python within ArcGIS Pro (via the Python Window).

Running the following lines:




from arcgis.gis import GIS
from arcgis.features import FeatureLayer

gis = GIS(url = '', username='nne\\username', password='my_password')




 I am met with this error:




Exception                                 Traceback (most recent call last)
In  [10]:
Line 2:     gis = GIS(url = '', username='nne\\cameronam', password='my_password')

File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\, in __init__:
Line 585:   raise e

File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\, in __init__:
Line 524:   self._portal = _portalpy.Portal(

File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\_impl\, in __init__:
Line 205:   self.con = Connection(

File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\_impl\_con\, in __init__:
Line 344:   self._create_session()

File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\_impl\_con\, in _create_session:
Line 691:   self._session.auth = EsriWindowsAuth(

File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\auth\_auth\, in __init__:
Line 84:    raise Exception("Please ensure gssapi is installed")




`gssapi` IS already installed, as confirmed when I went to the Python command prompt and tried to install it:

(arcgispro-py3) C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3>pip install gssapi
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: gssapi in c:\program files\arcgis\pro\bin\python\envs\arcgispro-py3\lib\site-packages (1.8.1)
Requirement already satisfied: decorator in c:\program files\arcgis\pro\bin\python\envs\arcgispro-py3\lib\site-packages (from gssapi) (5.1.1)


My colleague succeeded in establishing the connection using her creds on her own machine, without being thrown an error related to 'gssapi'.

gis = GIS("", "nne\\her_username", "her_password")   


Has anyone got any idea for a resolution?



0 Kudos
4 Replies
Occasional Contributor II

There's a thread on this that might be of interest: Please ensure gssapi is installed - Esri Community

But an easy fix might be to just use gis = GIS("pro") instead.

0 Kudos
New Contributor

Thanks, Joseph. Using gis = GIS("pro") withing Pro seems to have done the trick. But I assume its working correctly depends on my currently being logged into my Pro account. If I write this script in a Notebook, publish the Notebook to AGOL, and try to use it for the purpose of a scheduled task, the GIS connection would need to explicitly established with reference to the organization's AGOL url and someone's credentials. Does that sound right?

0 Kudos
Occasional Contributor II

In an AGOL notebook, you can just use gis=GIS("home"). In fact, that might be preferred over hardcoded credentials. This way, credentials aren't exposed, and if you change your password, you don't have to edit your Notebook code.

That said, I think the bug that is discussed in the link I sent is probably not relevant in an AGOL Notebook anyway. Seems to be limited to Pro 3.1/Python API But I could be wrong about that.

New Contributor

Thanks so much for your help. Good to know I can just use GIS("home") from within AGOL.

0 Kudos