Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds session_name to login #141

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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