Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't login to tidal #43

Closed
Glog78 opened this issue Jan 18, 2022 · 21 comments
Closed

Can't login to tidal #43

Glog78 opened this issue Jan 18, 2022 · 21 comments

Comments

@Glog78
Copy link
Contributor

Glog78 commented Jan 18, 2022

tidalapi: Login failed: {"status":401,"error":"invalid_client","error_description":"Client with token *************** not found","sub_status":1005}
401 Client Error: Unauthorized for url: https://auth.tidal.com/v1/oauth2/device_authorization

thats happening since today :(

@xmalbertox
Copy link

Can confirm.
I believe to be an issue with the api tokens/keys used by tamland/python-tidal

The full error was:

ERROR    2022-01-18 15:30:22,789 [5825:TidalBackend-6 (_actor_loop)] tidalapi
  Login failed: {"status":401,"error":"invalid_client","sub_status":1005,"error_description":"Client with token **************** not found"}
ERROR    2022-01-18 15:30:22,790 [5825:TidalBackend-6 (_actor_loop)] pykka
  Unhandled exception in TidalBackend (urn:uuid:4c6797e0-963f-45b7-a0f6-a6f94755bfe6):
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/pykka/_actor.py", line 179, in _actor_loop
    self.on_start()
  File "/usr/lib/python3.10/site-packages/mopidy_tidal/backend.py", line 68, in on_start
    self.oauth_login_new_session(oauth_file)
  File "/usr/lib/python3.10/site-packages/mopidy_tidal/backend.py", line 35, in oauth_login_new_session
    self._session.login_oauth_simple(function=logger.info)
  File "/usr/lib/python3.10/site-packages/tidalapi/__init__.py", line 210, in login_oauth_simple
    login, future = self.login_oauth()
  File "/usr/lib/python3.10/site-packages/tidalapi/__init__.py", line 223, in login_oauth
    login, future = self._login_with_link()
  File "/usr/lib/python3.10/site-packages/tidalapi/__init__.py", line 237, in _login_with_link
    request.raise_for_status()
  File "/usr/lib/python3.10/site-packages/requests/models.py", line 953, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://auth.tidal.com/v1/oauth2/device_authorization

@Glog78
Copy link
Contributor Author

Glog78 commented Jan 18, 2022

yaronzz/Tidal-Media-Downloader#797 (comment) , this helps if you change the tidal config api object acordingly ... but not sure for how long

@tehkillerbee
Copy link
Owner

tehkillerbee commented Jan 18, 2022

@Glog78 Thanks for letting me know about this. I can confirm the issue. I have created an issue at python-tidal

@chicco64
Copy link

i can confirm the same problem too, thanks

@tehkillerbee
Copy link
Owner

It looks like python-tidal is not maintained any longer. At least, I have not seen much activity from the maintainer. Maybe it is time to switch to pyopenTIDAL?

@Glog78
Copy link
Contributor Author

Glog78 commented Jan 19, 2022

if you want a small bugfix which makes it work again , i have one but i guess you don't want those keys in your codebase so maybe a switch would make sense.

Edit -> additional Information -> pyopenTIDAL isn't packaged in for example arch right now , which might be troublesome for the people who want to package mopidy-tidal

@tehkillerbee
Copy link
Owner

@Glog78 Exactly, I would like to avoid these keys in the codebase. A way forward could be to provide these keys in the mopidy config.

You bring up a good point wrt. pyopenTIDAL. It would be nice to talk to the developer about packaging it/adding it to pypi.

@Glog78
Copy link
Contributor Author

Glog78 commented Jan 19, 2022

For the moment it would not be a bad idea to have 2 config lines more where people could add a client id and a client secret.
If they are set you can load those from the config files else you can fall back to python-tidal (if the maintainer shows up again)
He not being active might be connected with 0.7 work (earlier) and maybe he has some health troubles currently.

@chicco64
Copy link

I agree, we do a temporary fix to be able to make it work again shortly, what exactly would be the changes to be made?

@tehkillerbee
Copy link
Owner

@Glog78 At the moment, python-tidal does not provide a way to set these variables externally. I am not aware of a way to override the client_id and client_secret class variables from outside python-tidal.

Did you manage to find an easy way that does not require modifying python-tidal sources? In that case, feel free to share the PR (without the keys).

@Glog78
Copy link
Contributor Author

Glog78 commented Jan 19, 2022

censored << works like a charm ;) | backend.py

sorry i did just hack my way around the issue , i would need to get much deeper into mopidy to provide a clean pr ... aka understand how i best get the settings into this part of the code.

@Glog78
Copy link
Contributor Author

Glog78 commented Jan 19, 2022

<*** pr is done ***> no need for an outdated patch

@Glog78
Copy link
Contributor Author

Glog78 commented Jan 19, 2022

pull request is up

@tehkillerbee
Copy link
Owner

@Glog78 Woah, that was quick! I will take a look ASAP

@chicco64
Copy link

chicco64 commented Jan 19, 2022

Hi !
I just edited the following file by adding config.client_id //config.api_token//config.client_secret
'# nano /usr/local/lib/python3.7/dist-packages/mopidy_tidal/backend.py'

Now mopidy tidal authenticates again, but I cannot play any audio files !

journalctl -u mopidy | tail -5

Jan 19 17:34:54 test-c mopidy[685]: obj, end = self.raw_decode(s, idx=_w(s, 0).end())
Jan 19 17:34:54 test-c mopidy[685]: File "/usr/lib/python3.7/json/decoder.py", line 355, in raw_decode
Jan 19 17:34:54 test-c mopidy[685]: raise JSONDecodeError("Expecting value", s, err.value) from None
Jan 19 17:34:54 test-c mopidy[685]: json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Jan 19 17:34:54 test-c mopidy[685]: WARNING [Core-5] mopidy.core.tracklist Track is not playable: tidal:track:5575171:181327136:181327140

Can you help me ?
many thanks !

@Glog78
Copy link
Contributor Author

Glog78 commented Jan 19, 2022

@chicco64 wait a moment ... the pr is under review ;) once the pr is done you can update and just use
client_secret=somesecret
client_id=someid

in the config section of tidal in /etc/mopidy.conf or which other config file you use

@chicco64
Copy link

I await the final instructions, thanks

@Glog78
Copy link
Contributor Author

Glog78 commented Jan 19, 2022

@chicco64 also i advice you to read this yaronzz/Tidal-Media-Downloader#797 carefully ... , also remember that your authorization is buffered and you might want to delete it first before you try a new client_secret / client_id.

If i am right and you did everything correctly the client_id / client_secret might not be the right one for your subscription.

@chicco64
Copy link

I also tried to change the setting from quality = lossless to low but the player doesn't work
this is the error:

journalctl -u mopidy | tail -5
Jan 19 18:09:00 test-c mopidy[725]: request.raise_for_status()
Jan 19 18:09:00 test-c mopidy[725]: File "/usr/lib/python3/dist-packages/requests/models.py", line 940, in raise_for_status
Jan 19 18:09:00 test-c mopidy[725]: raise HTTPError(http_error_msg, response=self)
Jan 19 18:09:00 test-c mopidy[725]: requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://api.tidalhifi.com/v1/tracks/181327140/streamUrl?sessionId=089799b3-a7ea-482b-9e9b-9ea0012d9216&countryCode=ES&limit=999&soundQuality=LOW
Jan 19 18:09:00 test-c mopidy[725]: WARNING [Core-5] mopidy.core.tracklist Track is not playable: tidal:track:5575171:181327136:181327140

After inserting the new credentials as you indicated in the "gif photo" obviously I had to recreate the authorization json code.

my subscription is correct it always worked until yesterday

@Glog78
Copy link
Contributor Author

Glog78 commented Jan 19, 2022

@chicco64 it's not your subscription ... but there are multiple client id / client secret combinations with different possibilities. The client id / client secret pair mentioned in the other project seems to only work with people having a master subscription. My guess is your subscription is for looseless so you might need to use a different client id / client secret pair. I am not sure if it works but i would remove ~/.config/tidal-oauth.json and try out the id / secret pair very openly mention in this project -> https://github.com/Fokka-Engineering/libopenTIDAL :)

PS -> i tested on my end but for me this one doesn't work anymore

@tehkillerbee
Copy link
Owner

@Glog78 @chicco64 This issue has also been fixed by the author of tidalapi. Make sure to update to the latest version.

The PR works, but its challenging finding a client_id, client_secret combination that works correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants