N4S4 / synology-api

A Python wrapper around Synology API
MIT License
360 stars 137 forks source link

filestation.FileStation() - "Error 402 - Denied permission" on version 0.7.x #159

Closed tblaudez closed 5 months ago

tblaudez commented 5 months ago

Describe the bug I have a Python script that uses filestation.FileStation() to connect to a Synology NAS using a password and an OTP code, and with the secure flag set to True. After updating synology-api from version 0.6.3 to 0.7.1, the script now fails to log in with the following error :

Login failed: Error 402 - Denied permission

To Reproduce Steps to reproduce the behavior:

  1. Execute the following script with synology-api==0.6.3
    filestation.FileStation('<IP>', '<PORT>', '<USER>', '<PASSWORD>', secure=True, otp_code='<OTP>', debug=True).logout()
  2. Execute the same script with synology-api==0.7.1

Expected behavior Executing the script with synology-api==0.7.1 should not raise any error

Screenshots N/A

Desktop (please complete the following information):

Additional context N/A

N4S4 commented 5 months ago

Soon there will be a new release that might fix some login issue. We are looking for more reports that upload functions are working. Could you try to use the updated github version 7.1.1 and see if issue persist?

tblaudez commented 5 months ago

I've tried with the latest commit from main (9ada8fc) and the issues persists

N4S4 commented 5 months ago

It is a strange error because i do not have any issue logging in. I see the execution script ur using .logout are u trying to login right?

N4S4 commented 5 months ago

Could you try to split the script assigning the login to a var than do what you need to do?

test = filestation.FileStation('<IP>', '<PORT>', '<USER>', '<PASSWORD>', secure=True, otp_code='<OTP>', debug=True)

test.logout()
tblaudez commented 5 months ago

I used this syntax because this part of my script is merely a test to check if the given credentials are correct. So I just log in and log out immediately.

I tried again this time assigning Filestation to a variable but the issue persists (still on commit 9ada8fc).

N4S4 commented 5 months ago

That is strange. The only thing comes in my mind you can try to change is to change 'enable_syno_token' in auth to 'no' and see what happens. This is the only change made to the api lately.

def login(self, application: str) -> None:
        login_api = 'auth.cgi?api=SYNO.API.Auth'
        params = {'version': self._version, 'method': 'login', 'account': self._username,
                  'passwd': self._password, 'session': application, 'format': 'cookie', 'enable_syno_token':'yes'}

Could you try this?

fabtesta commented 5 months ago

The latest lib version works for me. I've forked this repo (#164) to add the test cases to cover possible differences from my environment, changing the test cases config values.

client info

dsm info

N4S4 commented 5 months ago

it seems like an isolated case, have you checked your DSM config? i know was working before but people testing did not find same or other issues, i will keep looking at comments but i will close the issue