DOI-BLM / requests-arcgis-auth

Authentication handler for using Esri ArcGIS for Server and Portal (ArcGIS Online) Token Authentication with Python Requests
22 stars 1 forks source link

Better exception handling when kerberos is not supported #18

Open pfoppe opened 7 years ago

pfoppe commented 7 years ago

scenario - developer tries to access service protected with MS Negotiate... but Kerberos is not supported (like the SPN is not set correctly). the code tries NTLM but if there is no password the NTLM module throws an error. Capture this and raise our own error with this information blatantly stated.

pfoppe commented 7 years ago

Here is the stack trace

Traceback (most recent call last): File "", line 1, in File "C:\tmp\lib\site-packages\requests\sessions.py", line 501, in get return self.request('GET', url, **kwargs) File "C:\tmp\lib\site-packages\requests\sessions.py", line 474, in request prep = self.prepare_request(req) File "C:\tmp\lib\site-packages\requests\sessions.py", line 407, in prepare_requ hooks=merge_hooks(request.hooks, self.hooks), File "C:\tmp\lib\site-packages\requests\models.py", line 306, in prepare self.prepare_auth(auth, url) File "C:\tmp\lib\site-packages\requests\models.py", line 543, in prepare_auth r = auth(self) File "requests_arcgis_auth\arcgis_auth.py", line 136, in call self._init(r) File "requests_arcgis_auth\arcgis_auth.py", line 151, in _init self._determine_auth_handler(r) File "requests_arcgis_auth\arcgis_auth.py", line 181, in _determine_auth_handler self._last_request = requests.head(r.url,auth=HttpNtlmAuth(self.username,self.password),verify=self.verify) File "C:\tmp\lib\site-packages\requests_ntlm\requests_ntlm.py", line 28, in __i self.domain, self.username = username.split('\', 1) AttributeError: 'NoneType' object has no attribute 'split'