tomeko12 / pyelectroluxconnect

A python module to communicate with Elecrolux Connectivity Platform
Apache License 2.0
25 stars 9 forks source link

pyelectroluxconnect.Session.LoginError: Unauthorized (401) when using "frigidaire" region #13

Closed pem884 closed 1 year ago

pem884 commented 1 year ago

I use another repository that has this as a dependency and started getting errors logging in a few hours ago. I noticed the recent commit 5605321 for APAC region, but I have a frigidaire product (so region="frigidaire"). I suspect the "frigidaire" endpoint may also need to be updated upstream (here) - I tried looking for info on this but wasn't able to get anywhere.

Steps to recreate: I updated my local pyelectroluxconnect to 0.3.17 and did the following:

Python 3.11.3 (tags/v3.11.3:f3909b8, Apr  4 2023, 23:49:59) [MSC v.1934 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> username = "myemail@domain.com"
>>> password = "hopeitsagoodone"
>>> import pyelectroluxconnect
>>> ses = pyelectroluxconnect.Session(username, password, region="frigidaire")
>>> ses.login()
Getting new auth token
Unauthorized (401)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python311\Lib\site-packages\pyelectroluxconnect\Session.py", line 1061, in login
    self._createToken()
  File "C:\Python311\Lib\site-packages\pyelectroluxconnect\Session.py", line 176, in _createToken
    raise LoginError(f'{err.message} ({err.status_code})') from None
pyelectroluxconnect.Session.LoginError: Unauthorized (401)

Related issue in other repo is https://github.com/mauro-midolo/homeassistant_electrolux_status/issues/115

tomeko12 commented 1 year ago

endpoints updated in 0.3.18

pem884 commented 1 year ago

Thank you so much. Result has changed but not resolved: I now receive a "403" / Forbidden error. I wonder if they are shuffling something else around on their end. Please advise if I can help with any further/different testing or research; perhaps it's just the frigidaire region. I would consider resetting my password etc. if you request.

I would also be happy to open a separate issue if you prefer, considering that the outcome is now "403" and not "401". Thank you again.

>>> ses.login()
Getting new auth token
Invalid API response: Forbidden (403)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python311\Lib\site-packages\pyelectroluxconnect\Session.py", line 1061, in login
    self._createToken()
  File "C:\Python311\Lib\site-packages\pyelectroluxconnect\Session.py", line 178, in _createToken
    raise ResponseError(err.status_code, err.message) from None
pyelectroluxconnect.Session.ResponseError: Invalid API response: Forbidden (403)
tomeko12 commented 1 year ago

What mobile app are You use to control this appliance?

pem884 commented 1 year ago

Apart from pyelectroluxconnect (as part of "homeassistant_electrolux_status" linked earlier), I use the Frigidaire android app (v2.88.0.80) where I can currently see the device.

I imagine it will not interest you, but in case it helps reveal anything of interest, the only device I use with it is a Frigidaire dehumidifier FGAC5044W1, PNC 9120760499 on FW v3.0.0_argo

tomeko12 commented 1 year ago

Please try to login with custom customApiBrand attribute:

ses = pyelectroluxconnect.Session(username, password, region="frigidaire", customApiBrand="Electrolux")

or

ses = pyelectroluxconnect.Session(username, password, region="frigidaire", customApiBrand="Electrolux-NA")
pem884 commented 1 year ago

Thank you. I still got 403 error using each of these (I tried both within the same session); here is an excerpt:

>>> ses = pyelectroluxconnect.Session(username, password, region="frigidaire", customApiBrand="Electrolux")
>>> ses.login()
Getting new auth token
Invalid API response: Forbidden (403)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python311\Lib\site-packages\pyelectroluxconnect\Session.py", line 1061, in login
    self._createToken()
  File "C:\Python311\Lib\site-packages\pyelectroluxconnect\Session.py", line 178, in _createToken
    raise ResponseError(err.status_code, err.message) from None
pyelectroluxconnect.Session.ResponseError: Invalid API response: Forbidden (403)
>>> ses = pyelectroluxconnect.Session(username, password, region="frigidaire", customApiBrand="Electrolux-NA")
>>> ses.login()
Getting new auth token
Invalid API response: Forbidden (403)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python311\Lib\site-packages\pyelectroluxconnect\Session.py", line 1061, in login
    self._createToken()
  File "C:\Python311\Lib\site-packages\pyelectroluxconnect\Session.py", line 178, in _createToken
    raise ResponseError(err.status_code, err.message) from None
pyelectroluxconnect.Session.ResponseError: Invalid API response: Forbidden (403)
tomeko12 commented 1 year ago

Fixed in 0.3.19