ooii / pySuez

Get your water consumption data from your Suez account (www.toutsurmoneau.fr)
Apache License 2.0
8 stars 12 forks source link

csrfToken #20

Closed alexandreaudrain closed 1 year ago

alexandreaudrain commented 1 year ago

Hi, I can't get answer fron toutsurmoneau :+1:

 self._token = result.group(1)
              ^^^^^^^^^^^^

AttributeError: 'NoneType' object has no attribute 'group'

I think they changed the token name from _csrf_token to csrfToken (somewhere around feb. the 7th), but since I'm too bad at regex and encounter unicode problems... I can't find any solution.

Do you encounter such problems ?

Kelesis commented 1 year ago

Edit : backslashes are interpreted by the post displayer, beware the code needs 4 backslashes for each separator, as regexp is interpreting backslashes as well. So I wrote 8 backslashes, for this post can display 4, for regexp can search for 2, for json inside html understands 1 ^^'

Hello, indeed csrf token has been moved inside the web page into an utf-8 escaped string ... the lines which were looking for the token have to be changed to

phrase = re.compile('csrfToken\\\\u0022\\\\u003A\\\\u0022(.*)\\\\u0022,\\\\u0022') result = phrase.search(response.content.decode('utf-8')) if result != None: self._token = result.group(1).encode().decode('unicode_escape') else: raise PySuezError("Can't get token.") self._headers = headers

unfortunately @ooii doesn't seem to be active anymore on this project.

alexandreaudrain commented 1 year ago

It works perfectly, thanx ! I was struggling with unicode…

ooii commented 8 months ago

Guys, I'm sorry for not responding to these issues. I was very busy with other stuff and, to be honest, the integration was not satisfactory for me, so I stopped using it (and looking to this repo). I got some complaints recently and decided to give a look and discovered all these issues. I'll try to bring a new and better integration that takes into consideration all the issues and sub-providers, and I'll try to make it doable from the UI. Please, be patient.

alexandreaudrain commented 8 months ago

Thank you for your time ! :)