From d7d4dfee6d2389c433a0a255892cbe4c10eaa558 Mon Sep 17 00:00:00 2001 From: "Larry.Brown" Date: Mon, 25 Oct 2021 08:12:19 -0500 Subject: [PATCH 1/2] adds session_name to api --- src/synology_dsm/synology_dsm.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/synology_dsm/synology_dsm.py b/src/synology_dsm/synology_dsm.py index 582cd269..78aa36b5 100644 --- a/src/synology_dsm/synology_dsm.py +++ b/src/synology_dsm/synology_dsm.py @@ -53,6 +53,7 @@ def __init__( timeout: int = None, device_token: str = None, debugmode: bool = False, + session_name: str = None, ): """Constructor method.""" self.username = username @@ -66,6 +67,7 @@ def __init__( self._session.verify = self._verify # Login + self.session_name = session_name self._session_id = None self._syno_token = None self._device_token = device_token @@ -152,6 +154,9 @@ def login(self, otp_code: str = None) -> bool: "format": "sid", } + if self.session_name is not None: + params['session'] = self.session_name + if otp_code: params["otp_code"] = otp_code if self._device_token: From 3889f50a934f9a76fe13e98cb7e6f291e7bb5970 Mon Sep 17 00:00:00 2001 From: "Larry.Brown" Date: Mon, 25 Oct 2021 08:28:42 -0500 Subject: [PATCH 2/2] adds session_name to readme --- README.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.rst b/README.rst index 753ab9a0..b2f9cd01 100644 --- a/README.rst +++ b/README.rst @@ -51,10 +51,13 @@ Constructor timeout=None, device_token=None, debugmode=False, + session_name=None ) ``device_token`` should be added when using a two-step authentication account, otherwise DSM will ask to login with a One Time Password (OTP) and requests will fail (see the login section for more details). +``session_name`` should be added when using a non admin account. + Default ``timeout`` is 10 seconds.