tehkillerbee / mopidy-tidal

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

tidal-oauth.json expires after 7 days - tidalapi-0.6.9 #49

Closed chicco64 closed 2 years ago

chicco64 commented 2 years ago

Hi, I must point out that the authorization created with tidal-oauth.json, after the new changes, expires after 7 days.

This problem had already been solved by you some time ago: https://github.com/tehkillerbee/mopidy-tidal/issues/37

It is possible to solve this too, it seems to me a fairly important fact. thank you

tehkillerbee commented 2 years ago

@chicco64 I have just checked on my PC that my oauth file >10 days old was loaded successfully from the expected folder. This is with tidalapi 0.6.9 and Mopidy-Tidal 0.2.6 from pypi

Can you confirm which versions you are using?

Please note that I have moved the json config to a different folder in the latest version of Mopidy-Tidal. This is to make sure that the json file can always be written to the correct folder, irrespective of how the user is starting Mopidy.

chicco64 commented 2 years ago

I think mopidy-tidal (2.0.3)

tehkillerbee commented 2 years ago

´pip3 show tidalapi Mopidy-tidal Mopidy` should do the trick!

chicco64 commented 2 years ago

Name: tidalapi Version: 0.6.9 Summary: Unofficial API for TIDAL music streaming service. Home-page: https://github.com/tamland/python-tidal Author: Thomas Amland Author-email: thomas.amland@googlemail.com License: LGPL Location: /usr/local/lib/python3.7/dist-packages Requires: requests Required-by: Mopidy-Tidal

Name: Mopidy-Tidal Version: 0.2.5 Summary: Tidal music service integration Home-page: https://github.com/tehkillerbee/mopidy-tidal Author: Johannes Linde Author-email: josaksel.dk@gmail.com License: Apache License, Version 2.0 Location: /usr/local/lib/python3.7/dist-packages Requires: requests, setuptools, Mopidy, tidalapi, Pykka Required-by:

Name: Mopidy Version: 3.2.0 Summary: Mopidy is an extensible music server written in Python Home-page: https://mopidy.com/ Author: Stein Magnus Jodal Author-email: stein.magnus@jodal.no License: Apache License, Version 2.0 Location: /usr/lib/python3/dist-packages Requires: Required-by: Mopidy-Tidal, Mopidy-MusicBox-Webclient, Mopidy-MPD

tehkillerbee commented 2 years ago

It looks like you are still running on Mopidy-Tidal 0.2.5. I would probably update it to the latest version from PyPi and see if that resolves your issue.

chicco64 commented 2 years ago

I certainly do, I write again as soon as I can check if the problem reappears. many thanks !

tehkillerbee commented 2 years ago

FYI, I have just updated mopidy-tidal to version 0.2.7. This will move the oauth json file into a subfolder, requiring re-auth again :)

chicco64 commented 2 years ago

HI ! I find today that some json created 7 days ago (mopidy-tidal 0.2.5) and inserted in the new version 0.2.6 (yesterday fully functional) have expired today. is there a difference between the json generated with mopidy-tidal 0.2.5 and those with the new version 0.2.6 ? many thanks for your attention!

tehkillerbee commented 2 years ago

The format of the file itself has not been changed. It must be generated again when you sign in using a new API key (this was changed in tidalapi).I would suggest deleting all json files and re-auth as usual.

tehkillerbee commented 2 years ago

@chicco64 Can you send a snippet of your latest logs? That should give an idea of what is going wrong.

orenskl commented 2 years ago

Same issue here (started today), my log:

Feb 01 13:44:18 music mopidy[935]: INFO     [MainThread] mopidy.__main__ Starting Mopidy 3.0.1
Feb 01 13:44:18 music mopidy[935]: INFO     [MainThread] mopidy.config Loading config from builtin defaults
Feb 01 13:44:18 music mopidy[935]: INFO     [MainThread] mopidy.config Loading config from file:///usr/share/mopidy/conf.d/mopidy.conf
Feb 01 13:44:18 music mopidy[935]: INFO     [MainThread] mopidy.config Loading config from file:///etc/mopidy/mopidy.conf
Feb 01 13:44:18 music mopidy[935]: INFO     [MainThread] mopidy.config Loading config from command line options
Feb 01 13:44:19 music mopidy[935]: INFO     [MainThread] mopidy.__main__ Enabled extensions: mpd, stream, http, tidal, softwaremixer, m3u, file, iris
Feb 01 13:44:19 music mopidy[935]: INFO     [MainThread] mopidy.__main__ Disabled extensions: none
Feb 01 13:44:19 music mopidy[935]: INFO     [MainThread] mopidy.commands Starting Mopidy audio
Feb 01 13:44:19 music mopidy[935]: INFO     [MainThread] mopidy.commands Starting Mopidy backends: TidalBackend, FileBackend, M3UBackend, StreamBackend
Feb 01 13:44:19 music mopidy[935]: INFO     [TidalBackend-2] mopidy_tidal.backend Connecting to TIDAL.. Quality = LOSSLESS
Feb 01 13:44:20 music mopidy[935]: INFO     [TidalBackend-2] mopidy_tidal.backend Connecting to TIDAL.. using default client id & client secret from python-tidal
Feb 01 13:44:20 music mopidy[935]: INFO     [TidalBackend-2] mopidy_tidal.backend Could not load OAuth session from /var/lib/mopidy/tidal/tidal-oauth.json
Feb 01 13:44:20 music mopidy[935]: INFO     [TidalBackend-2] mopidy_tidal.backend Creating new OAuth session...
Feb 01 13:44:20 music mopidy[935]: INFO     [Audio-1] mopidy.audio.actor Audio output set to "alsasink"
Feb 01 13:44:20 music mopidy[935]: ERROR    [TidalBackend-2] tidalapi Login failed: {"status":401,"error":"invalid_client","sub_status":1005,"error_description":"Client with token 8SEZWa4J1NVC5U5Y not found"}
Feb 01 13:44:20 music mopidy[935]: ERROR    [TidalBackend-2] pykka Unhandled exception in TidalBackend (urn:uuid:71ccf8e6-f339-438b-9a00-f8a81e37200d):
Feb 01 13:44:20 music mopidy[935]: Traceback (most recent call last):
Feb 01 13:44:20 music mopidy[935]:   File "/usr/lib/python3/dist-packages/pykka/_actor.py", line 186, in _actor_loop
Feb 01 13:44:20 music mopidy[935]:     self.on_start()
Feb 01 13:44:20 music mopidy[935]:   File "/usr/local/lib/python3.8/dist-packages/mopidy_tidal/backend.py", line 84, in on_start
Feb 01 13:44:20 music mopidy[935]:     self.oauth_login_new_session(oauth_file)
Feb 01 13:44:20 music mopidy[935]:   File "/usr/local/lib/python3.8/dist-packages/mopidy_tidal/backend.py", line 33, in oauth_login_new_session
Feb 01 13:44:20 music mopidy[935]:     self._session.login_oauth_simple(function=logger.info)
Feb 01 13:44:20 music mopidy[935]:   File "/usr/local/lib/python3.8/dist-packages/tidalapi/__init__.py", line 213, in login_oauth_simple
Feb 01 13:44:20 music mopidy[935]:     login, future = self.login_oauth()
Feb 01 13:44:20 music mopidy[935]:   File "/usr/local/lib/python3.8/dist-packages/tidalapi/__init__.py", line 226, in login_oauth
Feb 01 13:44:20 music mopidy[935]:     login, future = self._login_with_link()
Feb 01 13:44:20 music mopidy[935]:   File "/usr/local/lib/python3.8/dist-packages/tidalapi/__init__.py", line 240, in _login_with_link
Feb 01 13:44:20 music mopidy[935]:     request.raise_for_status()
Feb 01 13:44:20 music mopidy[935]:   File "/usr/lib/python3/dist-packages/requests/models.py", line 940, in raise_for_status
Feb 01 13:44:20 music mopidy[935]:     raise HTTPError(http_error_msg, response=self)
Feb 01 13:44:20 music mopidy[935]: requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://auth.tidal.com/v1/oauth2/device_authorization
Feb 01 13:44:20 music mopidy[935]: ERROR    [MainThread] mopidy.commands Actor died: TidalBackend (urn:uuid:71ccf8e6-f339-438b-9a00-f8a81e37200d) stopped before handling the message
Feb 01 13:44:20 music mopidy[935]: INFO     [MainThread] mopidy.commands Starting Mopidy core
Feb 01 13:44:20 music mopidy[935]: INFO     [MainThread] mopidy.commands Starting Mopidy frontends: IrisFrontend, HttpFrontend, MpdFrontend
Feb 01 13:44:20 music mopidy[935]: INFO     [IrisFrontend-7] mopidy_iris.core Starting Iris 3.60.1
Feb 01 13:44:20 music mopidy[935]: INFO     [HttpFrontend-9] mopidy.http.actor HTTP server running at [::ffff:0.0.0.0]:6680
Feb 01 13:44:20 music mopidy[935]: INFO     [MainThread] mopidy_mpd.actor MPD server running at [::]:6600
Feb 01 13:44:20 music mopidy[935]: INFO     [MainThread] mopidy.comma
tehkillerbee commented 2 years ago

@orenskl This looks like a tidal API key has been changed again. Try to let us know what versions you are using: ´pip3 show tidalapi Mopidy-tidal Mopidy`

orenskl commented 2 years ago
Name: tidalapi
Version: 0.6.9
Summary: Unofficial API for TIDAL music streaming service.
Home-page: https://github.com/tamland/python-tidal
Author: Thomas Amland
Author-email: thomas.amland@googlemail.com
License: LGPL
Location: /usr/local/lib/python3.8/dist-packages
Requires: requests
Required-by: Mopidy-Tidal
---
Name: Mopidy-Tidal
Version: 0.2.7
Summary: Tidal music service integration
Home-page: https://github.com/tehkillerbee/mopidy-tidal
Author: Johannes Linde
Author-email: josaksel.dk@gmail.com
License: Apache License, Version 2.0
Location: /usr/local/lib/python3.8/dist-packages
Requires: requests, Mopidy, Pykka, tidalapi, setuptools
Required-by: 
---
Name: Mopidy
Version: 3.0.1
Summary: Mopidy is an extensible music server written in Python
Home-page: https://mopidy.com/
Author: Stein Magnus Jodal
Author-email: stein.magnus@jodal.no
License: Apache License, Version 2.0
Location: /usr/lib/python3/dist-packages
Requires: 
Required-by: Mopidy-Tidal, Mopidy-Iris
tehkillerbee commented 2 years ago

Closing this as the issue should be fixed in latest tidalapi 0.6.10.

Make sure to upgrade tidalapi to the latest version. You might also need to delete the json file and recreate it.

pip3 install --upgrade --force-reinstall tidalapi
cameronneylon commented 2 years ago

Hi, I seem to be having a similar issue here. I've just upgraded to tidalapi 0.6.10 and checked versions of Mopidy (3.2.0) and Mopidy-Tidal (0.2.7). Any guidance would be appreciated. Was working great up to this point!

I get what appears to be an identical error to orenskl above. I'm guessing I'm doing something wrong with respect to getting rid of the json oauth file but it doesn't seem to actually be there to delete.

The directory /var/lib/mopidy/tidal exists but it doesn't have any file in it. I'm running mopidy as as system service with user mopidy and I think I've got permissions correct:

pi@music-server:~ $ ls -al /var/lib/mopidy/
total 40
drwxr-xr-x 10 mopidy audio 4096 Feb 13 14:03 .
drwxr-xr-x 44 root   root  4096 Jan  6 17:36 ..
drwx------  4 mopidy audio 4096 Jan 30 17:41 .cache
drwx------  3 mopidy audio 4096 Dec 14 18:26 .config
drwxr-xr-x  2 mopidy audio 4096 Dec 14 16:35 http
drwxr-xr-x  2 mopidy audio 4096 Dec 14 16:35 iris
drwxr-xr-x  3 mopidy audio 4096 Dec 15 18:00 local
drwxr-xr-x  2 mopidy audio 4096 Aug 30 20:37 m3u
drwxr-xr-x  3 mopidy audio 4096 Feb 13 14:03 spotify
drwxr-xr-x  2 mopidy audio 4096 Feb 13 14:03 tidal

journal on mopidy startup:

Feb 13 14:03:10 music-server mopidy[12140]: INFO     [TidalBackend-3] mopidy_tidal.backend Connecting to TIDAL.. Quality = LOSSLESS
Feb 13 14:03:10 music-server mopidy[12140]: INFO     [TidalBackend-3] mopidy_tidal.backend Connecting to TIDAL.. using default client id & client secret from python-tidal
Feb 13 14:03:10 music-server mopidy[12140]: INFO     [TidalBackend-3] mopidy.internal.path Creating dir file:///var/lib/mopidy/tidal
Feb 13 14:03:10 music-server mopidy[12140]: INFO     [TidalBackend-3] mopidy_tidal.backend Could not load OAuth session from /var/lib/mopidy/tidal/tidal-oauth.json
Feb 13 14:03:10 music-server mopidy[12140]: INFO     [TidalBackend-3] mopidy_tidal.backend Creating new OAuth session...
Feb 13 14:03:10 music-server mopidy[12140]: INFO     [Audio-2] mopidy.audio.actor Audio output set to "audioresample ! audioconvert ! audio/x-raw,rate=48000,channels=2,format=S16LE ! wavenc ! filesink location=/tmp/snapfifo"
Feb 13 14:03:10 music-server mopidy[12140]: ERROR    [TidalBackend-3] tidalapi Login failed: {"status":401,"error":"invalid_client","error_description":"Client with token 8SEZWa4J1NVC5U5Y not found","sub_status":1005}
Feb 13 14:03:10 music-server mopidy[12140]: ERROR    [TidalBackend-3] pykka Unhandled exception in TidalBackend (urn:uuid:b67dfbd9-9c29-427d-93b6-9092a44d5d2c):
Feb 13 14:03:10 music-server mopidy[12140]: Traceback (most recent call last):
Feb 13 14:03:10 music-server mopidy[12140]:   File "/usr/lib/python3/dist-packages/pykka/_actor.py", line 186, in _actor_loop
Feb 13 14:03:10 music-server mopidy[12140]:     self.on_start()
Feb 13 14:03:10 music-server mopidy[12140]:   File "/usr/local/lib/python3.9/dist-packages/mopidy_tidal/backend.py", line 84, in on_start
Feb 13 14:03:10 music-server mopidy[12140]:     self.oauth_login_new_session(oauth_file)
Feb 13 14:03:10 music-server mopidy[12140]:   File "/usr/local/lib/python3.9/dist-packages/mopidy_tidal/backend.py", line 33, in oauth_login_new_session
Feb 13 14:03:10 music-server mopidy[12140]:     self._session.login_oauth_simple(function=logger.info)
Feb 13 14:03:10 music-server mopidy[12140]:   File "/usr/local/lib/python3.9/dist-packages/tidalapi/__init__.py", line 213, in login_oauth_simple
Feb 13 14:03:10 music-server mopidy[12140]:     login, future = self.login_oauth()
Feb 13 14:03:10 music-server mopidy[12140]:   File "/usr/local/lib/python3.9/dist-packages/tidalapi/__init__.py", line 226, in login_oauth
Feb 13 14:03:10 music-server mopidy[12140]:     login, future = self._login_with_link()
Feb 13 14:03:10 music-server mopidy[12140]:   File "/usr/local/lib/python3.9/dist-packages/tidalapi/__init__.py", line 240, in _login_with_link
Feb 13 14:03:10 music-server mopidy[12140]:     request.raise_for_status()
Feb 13 14:03:10 music-server mopidy[12140]:   File "/usr/lib/python3/dist-packages/requests/models.py", line 943, in raise_for_status
Feb 13 14:03:10 music-server mopidy[12140]:     raise HTTPError(http_error_msg, response=self)
Feb 13 14:03:10 music-server mopidy[12140]: requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://auth.tidal.com/v1/oauth2/device_authorization
Feb 13 14:03:10 music-server mopidy[12140]: ERROR    [MainThread] mopidy.commands Actor died: TidalBackend (urn:uuid:b67dfbd9-9c29-427d-93b6-9092a44d5d2c) stopped before handling the message
Feb 13 14:03:11 music-server mopidy[12140]: INFO     [SpotifyEventLoop] mopidy_spotify.backend Logged in to Spotify in online mode
Feb 13 14:03:11 music-server mopidy[12140]: INFO     [SpotifyBackend-8] mopidy_spotify.web Logged into Spotify Web API as 1131716619
tehkillerbee commented 2 years ago

This issue indicates that you are somehow still using the old tidalapi I tried installing upgrading to 0.6.10 on a different PC, and I got the same issue as you.

EDIT: I needed to delete my json file before I could sign in again. Therefore, make sure to delete it after upgrading to latest tidalapi

cameronneylon commented 2 years ago

Thanks so much @tehkillerbee So when I did:

sudo pip3 show tidalapi

It showed v0.6.9 so therefore I did the upgrade with sudo:

sudo pip3 install --upgrade --force-reinstall tidalapi

It then updated in the correct library location. A mopidy restart, and reauthenticating and everything is working once more. Thanks for the rapid response!