From d15d2ca6654aab141539dc150fac5938a019fb3f Mon Sep 17 00:00:00 2001 From: Miguel Ferrer Date: Fri, 1 Jul 2022 10:02:58 -0500 Subject: [PATCH 01/14] fix: support kwargs for create_subscription --- microsoftgraph/webhooks.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/microsoftgraph/webhooks.py b/microsoftgraph/webhooks.py index f19b12b..b669c50 100644 --- a/microsoftgraph/webhooks.py +++ b/microsoftgraph/webhooks.py @@ -24,6 +24,7 @@ def create_subscription( resource: str, expiration_datetime: datetime, client_state: str = None, + **kwargs, ) -> Response: """Creates a subscription to start receiving notifications for a resource. @@ -50,6 +51,7 @@ def create_subscription( "expirationDateTime": expiration_datetime, "clientState": client_state, } + data.update(kwargs) return self._client._post(self._client.base_url + "subscriptions", json=data) @token_required From e692bb9f9901d2205e1c7381c5b42fb8bc93e173 Mon Sep 17 00:00:00 2001 From: Miguel Ferrer Date: Fri, 1 Jul 2022 10:04:35 -0500 Subject: [PATCH 02/14] feat: add new params to create_event --- microsoftgraph/calendar.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/microsoftgraph/calendar.py b/microsoftgraph/calendar.py index c6c16b7..a583576 100644 --- a/microsoftgraph/calendar.py +++ b/microsoftgraph/calendar.py @@ -60,6 +60,9 @@ def create_event( location: str, calendar_id: str = None, content_type: str = "HTML", + attendees: list = None, + is_online_meeting: bool = False, + online_meeting_provider: str = 'teamsForBusiness', **kwargs, ) -> Response: """Create an event in the user's default calendar or specified calendar. @@ -102,7 +105,15 @@ def create_event( "timeZone": end_timezone, }, "location": {"displayName": location}, + "isOnlineMeeting": is_online_meeting, } + + if is_online_meeting: + body["onlineMeetingProvider"] = online_meeting_provider + + if attendees: + body["attendees"] = attendees + body.update(kwargs) url = "me/calendars/{}/events".format(calendar_id) if calendar_id is not None else "me/events" return self._client._post(self._client.base_url + url, json=body) From 8c45151eeb4483d3b20cf49562857809db298d9a Mon Sep 17 00:00:00 2001 From: Miguel Ferrer Date: Fri, 1 Jul 2022 10:10:59 -0500 Subject: [PATCH 03/14] bump version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index c114174..768a507 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ def read(fname): setup( name="microsoftgraph-python", - version="1.1.3", + version="1.1.4", description="API wrapper for Microsoft Graph written in Python", long_description=read("README.md"), url="https://github.com/GearPlug/microsoftgraph-python", From 750251097d22c61fac454f2c323525d73ce251b3 Mon Sep 17 00:00:00 2001 From: Austin Howard Date: Thu, 17 Nov 2022 16:15:34 -0600 Subject: [PATCH 04/14] Remove errant kw substitution --- microsoftgraph/mail.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoftgraph/mail.py b/microsoftgraph/mail.py index c8a43b6..ffceb4c 100644 --- a/microsoftgraph/mail.py +++ b/microsoftgraph/mail.py @@ -29,7 +29,7 @@ def list_messages(self, folder_id: str = None, params: dict = None) -> Response: Returns: Response: Microsoft Graph Response. """ - url = "me/mailFolders/{id}/messages".format(folder_id) if folder_id else "me/messages" + url = "me/mailFolders/{}/messages".format(folder_id) if folder_id else "me/messages" return self._client._get(self._client.base_url + url, params=params) @token_required From 915303ed901071a153ed8c81f908a2bcd11b2548 Mon Sep 17 00:00:00 2001 From: Miguel Ferrer Date: Thu, 17 Nov 2022 18:07:30 -0500 Subject: [PATCH 05/14] bump ver --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 768a507..1bbaa81 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ def read(fname): setup( name="microsoftgraph-python", - version="1.1.4", + version="1.1.5", description="API wrapper for Microsoft Graph written in Python", long_description=read("README.md"), url="https://github.com/GearPlug/microsoftgraph-python", From 58ec24685f2cf577a6dd20afc38196610bfad72e Mon Sep 17 00:00:00 2001 From: Miguel Ferrer Date: Mon, 27 Mar 2023 15:38:36 -0500 Subject: [PATCH 06/14] feat: pyproject.toml --- pyproject.toml | 18 ++++++++++++++++++ setup.py | 24 ------------------------ 2 files changed, 18 insertions(+), 24 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..bf8ba5b --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,18 @@ +[tool.poetry] +name = "microsoftgraph-python" +version = "1.1.6" +description = "API wrapper for Microsoft Graph written in Python" +authors = ["Miguel Ferrer "] +license = "MIT" +readme = "README.md" +packages = [{include = "microsoftgraph"}] + +[tool.poetry.dependencies] +python = "^3.7" +requests = "^2.26.0" + + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" + diff --git a/setup.py b/setup.py deleted file mode 100644 index 1bbaa81..0000000 --- a/setup.py +++ /dev/null @@ -1,24 +0,0 @@ -import os -from setuptools import setup - - -def read(fname): - return open(os.path.join(os.path.dirname(__file__), fname)).read() - - -setup( - name="microsoftgraph-python", - version="1.1.5", - description="API wrapper for Microsoft Graph written in Python", - long_description=read("README.md"), - url="https://github.com/GearPlug/microsoftgraph-python", - long_description_content_type="text/markdown", - author="Miguel Ferrer, Nerio Rincon, Yordy Gelvez", - author_email="ingferrermiguel@gmail.com", - license="MIT", - packages=["microsoftgraph"], - install_requires=[ - "requests", - ], - zip_safe=False, -) From 9b259029aff8be090a870488b3637a316f51fc4f Mon Sep 17 00:00:00 2001 From: lrd3k Date: Fri, 16 Feb 2024 16:11:25 -0500 Subject: [PATCH 07/14] fix: Changed Bearer por OAuth --- microsoftgraph/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/microsoftgraph/client.py b/microsoftgraph/client.py index e42dbd8..ae8852a 100644 --- a/microsoftgraph/client.py +++ b/microsoftgraph/client.py @@ -248,7 +248,7 @@ def _request(self, method, url, headers=None, **kwargs) -> Response: _headers = { "Accept": "application/json", } - _headers["Authorization"] = "Bearer " + self.token["access_token"] + _headers["Authorization"] = "JWT " + self.token["access_token"] if headers: _headers.update(headers) if self.requests_hooks: @@ -260,7 +260,7 @@ def _request(self, method, url, headers=None, **kwargs) -> Response: def _parse(self, response) -> Response: status_code = response.status_code r = Response(original=response) - if status_code in (200, 201, 202, 204, 206): + if status_code < 299: return r elif status_code == 400: raise exceptions.BadRequest(r.data) From ba6b438a0d025d75b6cb87db4784443149610dfe Mon Sep 17 00:00:00 2001 From: lrd3k Date: Thu, 22 Feb 2024 14:47:23 -0500 Subject: [PATCH 08/14] feat: Added extra headers validation --- microsoftgraph/client.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/microsoftgraph/client.py b/microsoftgraph/client.py index ae8852a..019e7cf 100644 --- a/microsoftgraph/client.py +++ b/microsoftgraph/client.py @@ -248,9 +248,15 @@ def _request(self, method, url, headers=None, **kwargs) -> Response: _headers = { "Accept": "application/json", } - _headers["Authorization"] = "JWT " + self.token["access_token"] + if headers: _headers.update(headers) + + if headers in ("JWT_REQUIRED"): + _headers["Authorization"] = "JWT " + self.token["access_token"] + + _headers["Authorization"] = "Bearer " + self.token["access_token"] + if self.requests_hooks: kwargs.update({"hooks": self.requests_hooks}) if "Content-Type" not in _headers: From 2473dd64e70cfb3fe6bcb04306067bb1fb5d2fd7 Mon Sep 17 00:00:00 2001 From: lrd3k Date: Thu, 22 Feb 2024 14:48:55 -0500 Subject: [PATCH 09/14] feat: Updated version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index bf8ba5b..c6d0197 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "microsoftgraph-python" -version = "1.1.6" +version = "1.1.7" description = "API wrapper for Microsoft Graph written in Python" authors = ["Miguel Ferrer "] license = "MIT" From 814610b5f110d41ec5c19d23c12aab21baf309ca Mon Sep 17 00:00:00 2001 From: Diego Manrique Date: Wed, 3 Apr 2024 11:05:49 -0500 Subject: [PATCH 10/14] update version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c6d0197..fc6a270 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ name = "microsoftgraph-python" version = "1.1.7" description = "API wrapper for Microsoft Graph written in Python" -authors = ["Miguel Ferrer "] +authors = ["Gearplug Team "] license = "MIT" readme = "README.md" packages = [{include = "microsoftgraph"}] From ac2d0cae5700dcd2e63be1d7c4f77986e2d7d67b Mon Sep 17 00:00:00 2001 From: lrd3k Date: Wed, 3 Apr 2024 12:22:43 -0500 Subject: [PATCH 11/14] hotfix: Updated headers --- microsoftgraph/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/microsoftgraph/client.py b/microsoftgraph/client.py index 019e7cf..bb866ab 100644 --- a/microsoftgraph/client.py +++ b/microsoftgraph/client.py @@ -252,8 +252,8 @@ def _request(self, method, url, headers=None, **kwargs) -> Response: if headers: _headers.update(headers) - if headers in ("JWT_REQUIRED"): - _headers["Authorization"] = "JWT " + self.token["access_token"] + if headers in ("JWT_REQUIRED"): + _headers["Authorization"] = "JWT " + self.token["access_token"] _headers["Authorization"] = "Bearer " + self.token["access_token"] From ead19309315a40a88b71b24f42dfeb13e8521613 Mon Sep 17 00:00:00 2001 From: Diego Manrique Date: Wed, 3 Apr 2024 12:48:03 -0500 Subject: [PATCH 12/14] update version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index fc6a270..6601e4d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "microsoftgraph-python" -version = "1.1.7" +version = "1.1.8" description = "API wrapper for Microsoft Graph written in Python" authors = ["Gearplug Team "] license = "MIT" From e218b9e10ddc5b992326743514d60269ce3e80a3 Mon Sep 17 00:00:00 2001 From: lrd3k Date: Mon, 8 Apr 2024 16:19:09 -0500 Subject: [PATCH 13/14] hotfix: Removed headers validation as its done via integration (controller connection) --- microsoftgraph/client.py | 3 --- pyproject.toml | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/microsoftgraph/client.py b/microsoftgraph/client.py index bb866ab..ee43957 100644 --- a/microsoftgraph/client.py +++ b/microsoftgraph/client.py @@ -252,9 +252,6 @@ def _request(self, method, url, headers=None, **kwargs) -> Response: if headers: _headers.update(headers) - if headers in ("JWT_REQUIRED"): - _headers["Authorization"] = "JWT " + self.token["access_token"] - _headers["Authorization"] = "Bearer " + self.token["access_token"] if self.requests_hooks: diff --git a/pyproject.toml b/pyproject.toml index fc6a270..6601e4d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "microsoftgraph-python" -version = "1.1.7" +version = "1.1.8" description = "API wrapper for Microsoft Graph written in Python" authors = ["Gearplug Team "] license = "MIT" From 09e334dfc9c9e72004a5ea29fd49789d7c312204 Mon Sep 17 00:00:00 2001 From: Diego Manrique <46985074+damanrique@users.noreply.github.com> Date: Mon, 8 Apr 2024 16:40:26 -0500 Subject: [PATCH 14/14] Update pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 6601e4d..2d69aac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "microsoftgraph-python" -version = "1.1.8" +version = "1.1.8.1" description = "API wrapper for Microsoft Graph written in Python" authors = ["Gearplug Team "] license = "MIT"