diff --git a/connectors/sources/outlook.py b/connectors/sources/outlook.py index 47a495162..1f3573fb0 100644 --- a/connectors/sources/outlook.py +++ b/connectors/sources/outlook.py @@ -44,6 +44,7 @@ html_to_text, iso_utc, retryable, + url_encode, ) RETRIES = 3 @@ -410,7 +411,8 @@ async def _fetch_token(self): ) async def get_users(self): access_token = await self._fetch_token() - url = f"https://graph.microsoft.com/v1.0/users?$top={TOP}" + filter_ = url_encode("accountEnabled eq true") + url = f"https://graph.microsoft.com/v1.0/users?$top={TOP}&$filter={filter_}" while True: try: async with self._get_session.get( diff --git a/tests/sources/test_outlook.py b/tests/sources/test_outlook.py index 31cc507c2..213717112 100644 --- a/tests/sources/test_outlook.py +++ b/tests/sources/test_outlook.py @@ -420,7 +420,10 @@ def side_effect_function(url, headers): Args: url, ssl: Params required for get call """ - if url == "https://graph.microsoft.com/v1.0/users?$top=999": + if ( + url + == "https://graph.microsoft.com/v1.0/users?$top=999&$filter=accountEnabled%20eq%20true" + ): return get_json_mock( mock_response={ "@odata.nextLink": "https://graph.microsoft.com/v1.0/users?$top=999&$skipToken=fake-skip-token",