From 33fac3b88744467142c7b0f8cc320f78be30a76e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20N=C3=89METH?= Date: Tue, 9 Jul 2019 10:59:20 +0200 Subject: [PATCH 1/3] handler.py: be able to use environment variables, like http_proxy --- o365_api/handler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/o365_api/handler.py b/o365_api/handler.py index 578f780..88ff9a7 100644 --- a/o365_api/handler.py +++ b/o365_api/handler.py @@ -353,7 +353,7 @@ async def run(self, loop): """ self.loop = loop - async with aiohttp.ClientSession(loop=loop) as session: + async with aiohttp.ClientSession(loop=loop, trust_env=True) as session: self.session = session coroutine_ = self.o365_log_foreman() await asyncio.gather(coroutine_, loop=self.loop) From b5ee0b40e07e2d7b89c4a1bea3795a8ac77be757 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20N=C3=89METH?= Date: Tue, 9 Jul 2019 11:09:20 +0200 Subject: [PATCH 2/3] handler.py: fix 404 results from Management API Although 'activityApiRoot' contains feed, I had to explicitly set otherwise I got 404s. --- o365_api/handler.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/o365_api/handler.py b/o365_api/handler.py index 88ff9a7..c41fe13 100644 --- a/o365_api/handler.py +++ b/o365_api/handler.py @@ -504,7 +504,7 @@ async def _get_subscription_list(self): """ Request a list of subscriptions from the API""" http_args = { - "url": urljoin(self.root_api, "subscriptions/list"), + "url": urljoin(self.root_api, "feed/subscriptions/list"), "headers": {"Authorization": self.token.return_authorization_string()}, "params": {"PublisherIdentifier": self.pub_id}, } @@ -685,7 +685,7 @@ def _start_subscription_args(self, content_type): """ Setup args for the API call to start subscriptions """ http_args = { - "url": urljoin(self.root_api, "subscriptions/start"), + "url": urljoin(self.root_api, "feed/subscriptions/start"), "headers": { "Authorization": self.token.return_authorization_string(), "Content-Type": "application/json", @@ -861,7 +861,7 @@ def _location_args(self, type_, window=None, endpoint=None): # If not a pagination request, you'll need parameters if not endpoint: http_args = { - "url": urljoin(self.root_api, "subscriptions/content"), + "url": urljoin(self.root_api, "feed/subscriptions/content"), "headers": {"Authorization": self.token.return_authorization_string()}, "params": { "PublisherIdentifier": self.pub_id, From 1aed01ba9c44794c292acdad55a3301cdcd19f0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20N=C3=89METH?= Date: Wed, 20 Nov 2019 10:18:27 +0100 Subject: [PATCH 3/3] handler.py: Set explicit session timeout to 600 seconds. --- o365_api/handler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/o365_api/handler.py b/o365_api/handler.py index c41fe13..85a7ef3 100644 --- a/o365_api/handler.py +++ b/o365_api/handler.py @@ -408,7 +408,7 @@ async def _api_get(self, content_type="application/json", encoding=None, **kwarg """ - async with self.session.get(ssl=False, **kwargs) as r: + async with self.session.get(ssl=True, timeout=600, **kwargs) as r: if r.status != 200: logging.error("{}, {}, {}".format(r.url, r.status, r.reason)) raise ValueError(