diff --git a/pyexchange/connection.py b/pyexchange/connection.py
index 51feb5d..b1cb8b5 100644
--- a/pyexchange/connection.py
+++ b/pyexchange/connection.py
@@ -6,6 +6,7 @@
"""
import requests
from requests_ntlm import HttpNtlmAuth
+from requests.auth import HTTPBasicAuth
import logging
@@ -39,7 +40,8 @@ def build_password_manager(self):
log.debug(u'Constructing password manager')
- self.password_manager = HttpNtlmAuth(self.username, self.password)
+ # self.password_manager = HttpNtlmAuth(self.username, self.password)
+ self.password_manager = HTTPBasicAuth(self.username, self.password)
return self.password_manager
@@ -62,6 +64,10 @@ def send(self, body, headers=None, retries=2, timeout=30, encoding=u"utf-8"):
try:
response = self.session.post(self.url, data=body, headers=headers, verify = self.verify_certificate)
+ if response.status_code == 401:
+ self.password_manager = HttpNtlmAuth(self.username, self.password)
+ self.session.auth = self.password_manager
+ response = self.session.post(self.url, data=body, headers=headers, verify = self.verify_certificate)
response.raise_for_status()
except requests.exceptions.RequestException as err:
log.debug(err.response.content)
diff --git a/pyexchange/exchange2010/__init__.py b/pyexchange/exchange2010/__init__.py
index d27d939..3bdf265 100644
--- a/pyexchange/exchange2010/__init__.py
+++ b/pyexchange/exchange2010/__init__.py
@@ -510,6 +510,8 @@ def _parse_response_for_get_event(self, response):
result['_conflicting_event_ids'] = self._parse_event_conflicts(response)
+ result[u'categories'] = self._parse_event_categories(response)
+
return result
def _parse_event_properties(self, response):
@@ -707,6 +709,10 @@ def _parse_event_conflicts(self, response):
conflicting_ids = response.xpath(u'//m:Items/t:CalendarItem/t:ConflictingMeetings/t:CalendarItem/t:ItemId', namespaces=soap_request.NAMESPACES)
return [id_element.get(u"Id") for id_element in conflicting_ids]
+ def _parse_event_categories(self, response):
+ categories = response.xpath(u'//m:Items/t:CalendarItem/t:Categories/t:String', namespaces=soap_request.NAMESPACES)
+ return [category.text for category in categories]
+
class Exchange2010FolderService(BaseExchangeFolderService):
diff --git a/tests/exchange2010/fixtures.py b/tests/exchange2010/fixtures.py
index 81cdfa1..ef50036 100644
--- a/tests/exchange2010/fixtures.py
+++ b/tests/exchange2010/fixtures.py
@@ -336,6 +336,10 @@
{resource.last_response:%Y-%m-%dT%H:%M:%SZ}
+
+ dino
+ saur
+
1
1
diff --git a/tests/exchange2010/test_get_event.py b/tests/exchange2010/test_get_event.py
index 3078bef..fce8455 100644
--- a/tests/exchange2010/test_get_event.py
+++ b/tests/exchange2010/test_get_event.py
@@ -98,6 +98,9 @@ def test_required_attendees_are_required(self):
def test_optional_attendees_are_optional(self):
assert sorted(self.event.optional_attendees) == sorted(OPTIONAL_PEOPLE)
+ def test_categories_are_correct(self):
+ assert sorted(self.event.categories) == sorted(["dino", "saur"])
+
def test_conflicting_event_ids(self):
assert self.event.conflicting_event_ids[0] == TEST_CONFLICT_EVENT.id