N4S4 / synology-api

A Python wrapper around Synology API
MIT License
368 stars 138 forks source link

Fix for not being able to log into Photos on DSM 7 #97

Closed fortysix2ahead closed 2 years ago

fortysix2ahead commented 2 years ago

Please verify fix on your device. At least on my NAS, running DSM 7.0, a login was not possible. It worked only after removing the session key from the params dict. Not sure if this happens also when trying to login to other Synology services. Tried with FileStation and it worked with the session key being present.

N4S4 commented 2 years ago

Nice catch..let me have a look as soon I am free

fortysix2ahead commented 2 years ago

Might be that Synology is not consistent here. I have more improvements regarding Photos. I forked your repo, you can already take a look.

N4S4 commented 2 years ago

That is great I will go through

N4S4 commented 2 years ago

Hi, so I am running DSM 7 and after running few tests I did not find any issue to log into photo even with session variable although there are few functions to be fixed i was able to use many of them without issues, could you tell me what is exactly what it says when you log in?

fortysix2ahead commented 2 years ago

Did more testing and now it gets weird. On a Macbook the original unpatched code runs without any issues. The same code fails on a Windows machine. The code line in question is this: https://github.com/N4S4/synology-api/blob/f342f0b33664299b0c7564b2d8eea00167169ec5/synology_api/auth.py#L41

The response on the Macbook is fine. On the Windows machine however, the response code is 200 with the payload being:

{"error":{"code":402},"success":false}

Then of course the next line session_request.json()['data']['sid'] fails as there's no 'data' in response.json(). Do we have an idea what error 402 means?

fortysix2ahead commented 2 years ago

According to https://global.download.synology.com/download/Document/Software/DeveloperGuide/Os/DSM/All/enu/DSM_Login_Web_API_Guide_enu.pdf error 402 means permission denied.

fortysix2ahead commented 2 years ago

Reverted changes to auth.py as they do not seem to be needed for Photos.

N4S4 commented 2 years ago

Strange i am working on a windows and linux both are working fine. I will just close the PR as no previous merge has been made. Also what improvements have u done to the photo module?

fortysix2ahead commented 2 years ago

Maybe that was a bit too early, this PR also contained a fix for not being able to count folder contents. Shall I reopen? Or make a new one?

N4S4 commented 2 years ago

Oh ok sorry my fault, can u make a new one without tests file? With just the fix Thank you for the support anyway

fortysix2ahead commented 2 years ago

Done.