Skip to content

Commit

Permalink
Merge pull request #214 from mcrowson/basic_auth_fallback
Browse files Browse the repository at this point in the history
Basic auth fallback
  • Loading branch information
mcrowson committed Nov 12, 2019
2 parents 2167da2 + 19f8e00 commit 168ec49
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# RETS Changelog

## 0.4.11

* Falls back to basic auth if digest returns 401 response on login

## 0.4.10

* Handles wildcard lookup_names for Standard XML responses.
Expand Down
2 changes: 1 addition & 1 deletion rets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from .exceptions import RETSException

__title__ = "rets"
__version__ = "0.4.10"
__version__ = "0.4.11"
__author__ = "REfindly"
__license__ = "MIT"
__copyright__ = "Copyright 2019 REfindly"
Expand Down
7 changes: 6 additions & 1 deletion rets/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,12 @@ def _request(self, capability, options=None, stream=False):

if response.status_code in [400, 401]:
if capability == "Login":
m = "Could not log into the RETS server with the provided credentials."
if self.http_authentication == 'digest':
# Fall back to base64 encoding auth method and try again
self.http_authentication = 'basic'
self.client.auth = HTTPBasicAuth(self.username, self.password)
return self._request(capability, options, stream)
m = "Could not log into the RETS server with the provided credentials in basic or digest."
else:
m = "The RETS server returned a 401 status code. You must be logged in to make this request."
raise NotLoggedIn(m)
Expand Down

0 comments on commit 168ec49

Please sign in to comment.