Closed jackiezxt closed 2 years ago
Please in order to troubleshoot post your data input
same issue
Nas: DS21Plus
Code used:
from synology_api import filestation ip = 'xx.xx.xx.xx port = '5001' username = 'xxxxxxxxxxxxxxxxxxx' password = 'xxxxxxxxxxxxxxxxxxx' fl = filestation.FileStation(ip, port, username, password, secure=True, cert_verify=True, dsm_version=7, debug=True, otp_code=None)
Exception:
Traceback (most recent call last): File "x\test.py", line 9, infl = filestation.FileStation(ip, port, username, password, secure=True, cert_verify=True, dsm_version=7, debug=True, otp_code=None) File "x\Python310\lib\site-packages\synology_api\filestation.py", line 34, in __init__ self.session.login('FileStation') File "x\Python310\lib\site-packages\synology_api\auth.py", line 42, in login self._sid = session_request.json()['data']['sid'] KeyError: 'data'
Okay so here is a possible cause of the exception:
I modified the login method in auth.Authentication to print session_request, it gave me this:
{'error': {'code': 403, 'errors': {'token': 'xxxxxxxx', 'types': [{'type': 'otp'}]}}, 'success': False}
It seems that I needed an otp password and since I use it it's working fine ! So @jackiezxt I suggest you to do the same to see what is the problem !
90% of the times is an initialization/settings problem, which means some settings or parameters might be incorrect and this leads to opening issues for something that users mistake. Thank you @Shaft-3796 for investigating your own issue and solving it!
Closed for inactivity
synology-api/auth.py line42 in login self._sid = session_request.json()['data']['sid'] KeyError: 'data'