tehkillerbee / mopidy-tidal

Tidal Backend plugin for Mopidy
Apache License 2.0
93 stars 28 forks source link

ERROR in initialisation: "Invalid token" (kgsOOmYk3zShYrNP) #19

Closed hmelder closed 4 years ago

hmelder commented 4 years ago

Hi, I powered a mopidy instance up just as always but now mopidy-tidal has an invalid token.

{"status":401,"subStatus":6004,"userMessage":"Invalid token"}
ERROR    2020-05-13 19:00:56,197 [13520:TidalBackend-3] pykka
  Unhandled exception in TidalBackend (urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-5a4b08ae0590):
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pykka/_actor.py", line 186, in _actor_loop
    self.on_start()
  File "/home/pi/.local/lib/python3.8/site-packages/mopidy_tidal/backend.py", line 35, in on_start
    if self._session.login(self._username, self._password):
  File "/home/pi/.local/lib/python3.8/site-packages/tidalapi/__init__.py", line 86, in login
    request.raise_for_status()
  File "/usr/lib/python3/dist-packages/requests/models.py", line 941, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://api.tidalhifi.com/v1/login/username?token=xxxxxxxxxxxxxxxx
ERROR    2020-05-13 19:00:56,203 [13520:MainThread] mopidy.commands
  Actor died: TidalBackend (urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-5a4b08ae0590) stopped before handling the message
tehkillerbee commented 4 years ago

Yes, the api token is not valid anymore. This is also apparent from the python-tidal package that mopidy-tidal depends on: https://github.com/tamland/python-tidal/issues

I have noticed that other (illegal?) tidal tools has updated their token although I am not exactly sure where this token has been obtained: hZ9wuySZCmpLLiui I have changed my python-tidal installation to use this token and it now works again. I suggest we wait for an update of the python-tidal package.

hmelder commented 4 years ago

Thanks for the new token! I updated the variable "self.api_token" and now it works.

~/.local/lib/python3.8/site-packages/tidalapi4mopidy/__init__.py
~/.local/lib/python3.8/site-packages/tidalapi/__init__.py
hmelder commented 4 years ago

I won't close the issue yet :) Until it's not fixed.

hmelder commented 4 years ago

Umm now my instance fetches ALAC files instead of FLAC from the tidal server. I installed a gstreamer extention (gstreamer1.0-libav) for ALAC decoding and now it works. But still..it's a bit weird.

tehkillerbee commented 4 years ago

Interesting. But in my case, I still stream M4A/AAC after changing the token (I do not have a premium subscription). So I think that is unrelated, unless you changed something else.

EDIT: Turns out it was indeed caused by the token. Python-tidal / tidalapi switched to a token that uses FLAC instead of ALAC for lossless streams as mentioned here

tehkillerbee commented 4 years ago

python-tidal / tidalapi has now been updated with the latest token as of ver. 0.6.5. I will now close this issue