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

Exception Handling - failed first request #14

Open pfoppe opened 7 years ago

pfoppe commented 7 years ago

When the first request fails (for whatever reason) the _token_acquired private var is still None for the next iteration (there may be others). When making a second request an exception is thrown:

resposne = s.get(URL) Traceback (most recent call last): File "", line 1, in File "C:\tmp_PYTHON\virtual_envs\blmpydev2\lib\site-packages\requests\sessions.py", line 501, in get return self.request('GET', url, kwargs) File "C:\tmp_PYTHON\virtual_envs\blmpydev2\lib\site-packages\requests\sessions.py", line 474, in request prep = self.prepare_request(req) File "C:\tmp_PYTHON\virtual_envs\blmpydev2\lib\site-packages\requests\sessions.py", line 407, in prepare_request hooks=merge_hooks(request.hooks, self.hooks), File "C:\tmp_PYTHON\virtual_envs\blmpydev2\lib\site-packages\requests\models.py", line 306, in prepare self.prepare_auth(auth, url) File "C:\tmp_PYTHON\virtual_envs\blmpydev2\lib\site-packages\requests\models.py", line 543, in prepare_auth r = auth(self) File "requests_arcgis_auth\arcgis_saml_auth.py", line 61, in call delta = datetime.now() - self._token_acquired TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'NoneType'**

Complete better exception handling on a failure.