Skip to content
This repository has been archived by the owner on Feb 9, 2025. It is now read-only.

Adds session_name to login #141

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.


Expand Down
5 changes: 5 additions & 0 deletions src/synology_dsm/synology_dsm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down