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

[BUG] <'User does not have a valid session'> #282

Closed
MrNowhereDan opened this issue Jan 21, 2022 · 10 comments
Closed

[BUG] <'User does not have a valid session'> #282

MrNowhereDan opened this issue Jan 21, 2022 · 10 comments
Labels
bug Something isn't working

Comments

@MrNowhereDan
Copy link

Describe the bug

Streamrip worked amazingly for a few sessions logged into Tidal HiFi.

But I now get this error, although I'm still logged into Tidal web player and am streaming fine. I tried logging out of Tidal and logging back in, and restarting Terminal.

Exception

Login failed {'status': 401, 'subStatus': 6001, 'userMessage': 'User does not have a valid session'}

at /usr/local/lib/python3.9/site-packages/streamrip/clients.py:976 in _login_by_access_token
972│ resp = self.session.get(
973│ "https://api.tidal.com/v1/sessions", headers=headers
974│ ).json()
975│ if resp.get("status", 200) != 200:
→ 976│ raise Exception(f"Login failed {resp}")
977│
978│ if str(resp.get("userId")) != str(user_id):
979│ raise Exception(f"User id mismatch {resp['userId']} v {user_id}")
980│

Command Used

rip url https://listen.tidal.com/album/63886176

Debug Traceback

DEBUG:streamrip:Config loaded
DEBUG:streamrip:Parsed urls: [('tidal', 'album', '63886176')]
DEBUG:streamrip:Searching for {'id': '63886176'} in database
DEBUG:streamrip:Executing SELECT EXISTS(SELECT 1 FROM downloads WHERE id=?)
DEBUG:streamrip:{'quality': 3, 'download_videos': True, 'user_id': 174287318, 'country_code': 'XX', 'access_token': 'eyJraWQiOiJ2OU1GbFhqWSIsImFsZyI6IkVTMjU2In0.eyJ0eXBlIjoibzJfYWNjZXNzIiwidWlkIjoxNzQyODczMTgsInNjb3BlIjoid19zdWIgcl91c3Igd191c3IiLCJnVmVyIjowLCJzVmVyIjoxLCJjaWQiOjIyMTksImV4cCI6MTY0MjgzMjgwMSwic2lkIjoiMTg3M2U5ODAtMTVlZi00N2QyLWJmYmUtNTYzZDMxNjNkYjcyIiwiaXNzIjoiaHR0cHM6Ly9hdXRoLnRpZGFsLmNvbS92MSJ9.g_tyqVo_AzR0AeB2fv2TIYAG6wkMYdzLPC0jiHA6-QXN4CZO1OZcd46tBDAv6N8Ougq2k5hET8WzffCrgYmxmQ', 'refresh_token': 'eyJraWQiOiJoUzFKYTdVMCIsImFsZyI6IkVTNTEyIn0.eyJ0eXBlIjoibzJfcmVmcmVzaCIsInVpZCI6MTc0Mjg3MzE4LCJzY29wZSI6Indfc3ViIHJfdXNyIHdfdXNyIiwiY2lkIjoyMjE5LCJzVmVyIjoxLCJnVmVyIjowLCJpc3MiOiJodHRwczovL2F1dGgudGlkYWwuY29tL3YxIn0.AYduUjMxTgxuO2drJ1DXyHhH41YDmeK3x_1lYL8N1HFYLEKMaW90EOP88HwCqKD37DUIHySRsB_IVUnZSM2ANCKzAAEyHKHZubCAc9NlaDRHTsTLYfvtSfrQzYyYbHXqd9ccg2vJmB9bBj6iaKi0KF0WalD9wJZksyKRaVBZ4_u6OKTo', 'token_expiry': 1642832801.090435}
DEBUG:streamrip:Logging in with access token

  Stack trace:

  12  /usr/local/lib/python3.9/site-packages/cleo/application.py:330 in run
       328│ 
       329│             try:
     → 330│                 exit_code = self._run(io)
       331│             except Exception as e:
       332│                 if not self._catch_exceptions:

  11  /usr/local/lib/python3.9/site-packages/rip/cli.py:759 in _run
       757│             logger.addHandler(fh)
       758│ 
     → 759│         super()._run(io)
       760│ 
       761│     def create_io(self, input=None, output=None, error_output=None):

  10  /usr/local/lib/python3.9/site-packages/cleo/application.py:425 in _run
       423│                 io.set_input(ArgvInput(argv))
       424│ 
     → 425│         exit_code = self._run_command(command, io)
       426│         self._running_command = None
       427│ 

   9  /usr/local/lib/python3.9/site-packages/cleo/application.py:432 in _run_command
       430│     def _run_command(self, command: Command, io: IO) -> int:
       431│         if self._event_dispatcher is None:
     → 432│             return command.run(io)
       433│ 
       434│         # Bind before the console.command event,

   8  /usr/local/lib/python3.9/site-packages/cleo/commands/base_command.py:118 in run
       116│         io.input.validate()
       117│ 
     → 118│         status_code = self.execute(io)
       119│ 
       120│         if status_code is None:

   7  /usr/local/lib/python3.9/site-packages/cleo/commands/command.py:85 in execute
        83│ 
        84│         try:
     →  85│             return self.handle()
        86│         except KeyboardInterrupt:
        87│             return 1

   6  /usr/local/lib/python3.9/site-packages/rip/cli.py:121 in handle
       119│ 
       120│         if urls:
     → 121│             core.handle_urls(";".join(urls))
       122│ 
       123│         if len(core) > 0:

   5  /usr/local/lib/python3.9/site-packages/rip/core.py:186 in handle_urls
       184│                 continue
       185│ 
     → 186│             self.handle_item(source, url_type, item_id)
       187│ 
       188│     def handle_item(self, source: str, media_type: str, item_id: str):

   4  /usr/local/lib/python3.9/site-packages/rip/core.py:198 in handle_item
       196│         :type item_id: str
       197│         """
     → 198│         client = self.get_client(source)
       199│ 
       200│         if media_type not in MEDIA_TYPES:

   3  /usr/local/lib/python3.9/site-packages/rip/core.py:360 in get_client
       358│         if not client.logged_in:
       359│             try:
     → 360│                 self.login(client)
       361│             except DeezloaderFallback:
       362│                 client = self.clients["deezloader"]

   2  /usr/local/lib/python3.9/site-packages/rip/core.py:385 in login
       383│         while True:
       384│             try:
     → 385│                 client.login(**creds)
       386│                 break
       387│             except AuthenticationError:

   1  /usr/local/lib/python3.9/site-packages/streamrip/clients.py:759 in login
        757│             else:
        758│                 logger.debug("Logging in with access token")
     →  759│                 self._login_by_access_token(access_token, user_id)
        760│         else:
        761│             logger.debug("Logging in as a new user")

  Exception

  Login failed {'status': 401, 'subStatus': 6001, 'userMessage': 'User does not have a valid session'}

  at /usr/local/lib/python3.9/site-packages/streamrip/clients.py:976 in _login_by_access_token
       972│         resp = self.session.get(
       973│             "https://api.tidal.com/v1/sessions", headers=headers
       974│         ).json()
       975│         if resp.get("status", 200) != 200:
    →  976│             raise Exception(f"Login failed {resp}")
       977│ 
       978│         if str(resp.get("userId")) != str(user_id):
       979│             raise Exception(f"User id mismatch {resp['userId']} v {user_id}")
       980│

Config File

Opening /Users/XXXX/Library/Application Support/streamrip/config.toml in default application

Operating System

MacOS

streamrip version

1.9.2

Screenshots and recordings

No response

Additional context

Thank you :)

@MrNowhereDan MrNowhereDan added the bug Something isn't working label Jan 21, 2022
@CanadianBaconBoi
Copy link
Contributor

A PR #285 has been created which will allow you to run rip config --tidal to fix it once pulled.

@MrNowhereDan
Copy link
Author

Thanks for your reply. I have visited #285 but I don't know what I need to do with its contents. How do I 'pull' #285? I'm new to Python and using Terminal on the Mac. Thanks for your help.

@CanadianBaconBoi
Copy link
Contributor

CanadianBaconBoi commented Jan 21, 2022

You're going to have to wait for @nathom to pull it into the dev and eventually master branch. There is nothing to be done on your part, however if you want it to work now, you could run these commands:
pip3 uninstall streamrip
pip3 install git+https://github.com/CanadianBaconBoi/streamrip@dev
These will install my version with working API credentials, you can audit the code changes at https://github.com/CanadianBaconBoi/streamrip/tree/dev

@MrNowhereDan
Copy link
Author

MrNowhereDan commented Jan 21, 2022

Successfully uninstalled streamrip-1.9.2

Successfully installed streamrip-1.9.2

rip url https://listen.tidal.com/album/63886176

Exception

Refresh failed

at /usr/local/lib/python3.9/site-packages/streamrip/clients.py:955 in _refresh_access_token
951│ (TIDAL_CLIENT_INFO["id"], TIDAL_CLIENT_INFO["secret"]),
952│ )
953│
954│ if resp.get("status", 200) != 200:
→ 955│ raise Exception("Refresh failed")
956│
957│ self.user_id = resp["user"]["userId"]
958│ self.country_code = resp["user"]["countryCode"]
959│ self.access_token = resp["access_token"]

@CanadianBaconBoi
Copy link
Contributor

Have you run rip config --tidal?

@MrNowhereDan
Copy link
Author

No, I will do that now. Thanks :)

@MrNowhereDan
Copy link
Author

Your device was successfully linked to your account

@MrNowhereDan
Copy link
Author

Wow. Thanks so much for the fix! I so appreciate it.

@nathom
Copy link
Owner

nathom commented Jan 22, 2022

Fixed in v1.9.3.

@nathom nathom closed this as completed Jan 22, 2022
@MrNowhereDan
Copy link
Author

Thank you 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants