mirror of
https://github.com/Googolplexed0/zotify.git
synced 2026-04-24 22:05:53 +03:00
[GH-ISSUE #48] [Bug Report] Token Auth MercuryException 403 #41
Labels
No labels
bug
considering
discussion
documentation
enhancement
enhancement
good first issue
help wanted
pull-request
question
stale
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/zotify#41
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @terrastrial on GitHub (Aug 12, 2025).
Original GitHub issue: https://github.com/Googolplexed0/zotify/issues/48
Bug Description
Inability to get past "logging in" stage to select downloadable songs. Entering zotify -s will allow for a search to be entered but when entered the same error is output. Was mass downloading from a playlist when I returned to find it timed out (I did not copy that code unfortunately), ctrl+c, and the next time i tried the same zotify -p that I had been using it gave the error, also restarted the terminal.
Bug Triggering Command
zotify -pError Traceback / Logs
Config File
{ "DEBUG": "True", "ROOT_PATH": "~/Music/Zotify Music", "SAVE_CREDENTIALS": "True", "CREDENTIALS_LOCATION": "", "OUTPUT": "", "OUTPUT_PLAYLIST": "{playlist}/{artist}_{song_name}", "OUTPUT_PLAYLIST_EXT": "{playlist}/{playlist_num}_{artist}_{song_name}", "OUTPUT_LIKED_SONGS": "Liked Songs/{artist}_{song_name}", "OUTPUT_SINGLE": "{artist}/{album}/{artist}_{song_name}", "OUTPUT_ALBUM": "{artist}/{album}/{album_num}_{artist}_{song_name}", "ROOT_PODCAST_PATH": "~/Music/Zotify Podcasts", "SPLIT_ALBUM_DISCS": "False", "MAX_FILENAME_LENGTH": "0", "BULK_WAIT_TIME": "2", "DOWNLOAD_REAL_TIME": "True", "TEMP_DOWNLOAD_DIR": "", "DOWNLOAD_PARENT_ALBUM": "False", "NO_COMPILATION_ALBUMS": "False", "REGEX_ENABLED": "False", "REGEX_TRACK_SKIP": "", "REGEX_EPISODE_SKIP": "", "REGEX_ALBUM_SKIP": "", "DOWNLOAD_FORMAT": "mp3", "DOWNLOAD_QUALITY": "auto", "TRANSCODE_BITRATE": "auto", "SONG_ARCHIVE_LOCATION": "", "DISABLE_SONG_ARCHIVE": "False", "DISABLE_DIRECTORY_ARCHIVES": "False", "SKIP_EXISTING": "True", "SKIP_PREVIOUSLY_DOWNLOADED": "False", "EXPORT_M3U8": "False", "M3U8_LOCATION": "", "M3U8_REL_PATHS": "True", "LIKED_SONGS_ARCHIVE_M3U8": "True", "DOWNLOAD_LYRICS": "True", "LYRICS_LOCATION": "", "ALWAYS_CHECK_LYRICS": "False", "LYRICS_MD_HEADER": "False", "LANGUAGE": "en", "STRICT_LIBRARY_VERIFY": "True", "MD_DISC_TRACK_TOTALS": "True", "MD_SAVE_GENRES": "True", "MD_ALLGENRES": "False", "MD_GENREDELIMITER": ", ", "MD_ARTISTDELIMITER": ", ", "MD_SAVE_LYRICS": "True", "ALBUM_ART_JPG_FILE": "False", "RETRY_ATTEMPTS": "1", "CHUNK_SIZE": "20000", "OAUTH_ADDRESS": "0.0.0.0", "REDIRECT_ADDRESS": "127.0.0.1", "PRINT_SPLASH": "False", "PRINT_PROGRESS_INFO": "True", "PRINT_SKIPS": "True", "PRINT_DOWNLOADS": "True", "PRINT_DOWNLOAD_PROGRESS": "True", "PRINT_URL_PROGRESS": "True", "PRINT_ALBUM_PROGRESS": "True", "PRINT_ARTIST_PROGRESS": "True", "PRINT_PLAYLIST_PROGRESS": "True", "PRINT_WARNINGS": "True", "PRINT_ERRORS": "True", "PRINT_API_ERRORS": "True", "FFMPEG_LOG_LEVEL": "error" }Zotify Version
Zotify v0.9.13
Additional Context
System:
Kernel: 6.8.0-71-generic arch: x86_64 bits: 64 compiler: gcc v: 13.3.0 clocksource: tsc
Desktop: Cinnamon v: 6.4.8 tk: GTK v: 3.24.41 wm: Muffin v: 6.4.1 vt: 7 dm: LightDM v: 1.30.0
Distro: Linux Mint 22.1 Xia base: Ubuntu 24.04 noble
Also I don´t know what "linted with pylint before pushing" means, sorry if I missed something
@terrastrial commented on GitHub (Aug 12, 2025):
I also tried restarting the terminal*
@trustosas commented on GitHub (Aug 12, 2025):
It affects the original main branch (the one I use), as well as other forks of Zotify (https://github.com/DraftKinner/zotify/issues/80)
@Googolplexed0 commented on GitHub (Aug 12, 2025):
Can you attach the debug
.logfile as well?This is an issue with librespot-python, which the original repo and all forks rely on. The API has been undergoing changes this month, so this is not unexpected. I would suggest you create an issue there. I will do some investigation to see if I can find a fix in the meantime.
@terrastrial commented on GitHub (Aug 12, 2025):
I'm looking for it for ya. I only installed linux for the first time this week and I am not a software person so it might take me a minute lol.
If you have any suggestions for where I can find the .log file I would appreciate it.
@mchlschlz commented on GitHub (Aug 12, 2025):
It seems to be that a credentials.json is created in ~/.local/share/zotify/
Removing it allows you to redo the auth process and it works for that session at least. Delete the credentials again to repeat. I can't seem to re-use authorization credentials.
@Googolplexed0 commented on GitHub (Aug 12, 2025):
Should be in your
ROOT_PATH. Added a debug print with21504fd72d(v0.9.14) to show this on running.@terrastrial commented on GitHub (Aug 13, 2025):
This is what you're looking for?
@Googolplexed0 commented on GitHub (Aug 13, 2025):
Yes. As I feared, the issue exists with the keymaster, which is above the scope of the librespot-python implementation we use. It seems to be happening across many other projects and is even affecting the original librespot library. This will require a fix from someone with more experience in OAuth and networking. Give some attention the the librespot issue to encourage a more serious investigation.
@IsaacAgulhas commented on GitHub (Aug 13, 2025):
Hi guys been swimming around the various repos that use/implement librespot (which includes this repo, the original zotify repo and all forks of zotify) as well as the various implementations/versions of librespot (java and python respectively)
The issue is with the mercury token generation and authorization, the solution is to change to login5 token authentication, however this is done in librespot itself and not in zotify, however zotify is the one that is choosing to use mercury auth process, and the login5 setup already exists in librespot so it can be implemented, here is a link to a contributor in the librespot java library that produced a patch for using login5 https://github.com/librespot-org/librespot-java/issues/1099 and that has resolved the issue
@Googolplexed0 since the main zotify repo does not look to be maintained and since your fork is very far ahead of dev (170 commits) it appears you or a contributor will need to implement a similar patch to use login5 token auth
I have a build of the main zotify running on my ubuntu server that I will be looking to implement the above mentioned patch and if I do so successfully I will openly share it here so you can do the same for yours and produce an official release
@nefariouslegion commented on GitHub (Aug 13, 2025):
Hey, dumb question but how do I actually implement this patch on Windows? When I download the file it has the .patch extension which when I try to run it just prompts the Open With screen.
@IsaacAgulhas commented on GitHub (Aug 13, 2025):
unfortunately that won't work as that is for the java version of the library, please wait for an official release
@Googolplexed0 commented on GitHub (Aug 14, 2025):
I did a bit of digging as well (great find on the Java implementation!) and came to a similar conclusion. We will need our own implementation of login5. Either you @IsaacAgulhas, I, or another contributor will need to create this since I am fairly certain kokarare1212 doesn't make feature updates anymore.
I will do my best to come up with a workable pull request, but the lower levels of OAuth are something I will have to learn as I go. May make some progress this weekend. If you make a successful implementation before I get anywhere, I will gladly piggyback off you and help do any cleaning required to make it pull-worthy to the upstream librespot-python library.
@qMvhmoud commented on GitHub (Aug 14, 2025):
I had the same issue with librespot-python, but I tried zotify and it worked for me once, then I got a 403 error. I guess it's an issue with the login endpoint, or maybe the authorization code only works once, which I doubt. Also, this package go-librespot works fine, but only on Linux/Docker. I was able to save the audio of all the songs I played while connected to the device, but it doesn't save each song individually, it saves them all as one combined file.
Edit:
I deleted the credentials.json file, logged in again, and tried to download another file, which worked.
@Googolplexed0 commented on GitHub (Aug 14, 2025):
There seems to have been a semi-successful python implementation here. Worth looking at when building ours.
@IsaacAgulhas commented on GitHub (Aug 14, 2025):
I tested the new python implementation by uninstalling my current librespot python package and installing the above mentioned one and it works pretty well.
The implementation for it was intense because in the librespot python library the login5 component was available as a proto and that made development quite challenging, not to mention the actual implementation of the authentication flow so i'm glad that is now off my hands.
As for this repo its going to be a challenge since the issue is not with the project but rather a dependency so I'm interested to see how you will solve it. In any case I wish you the best of luck, happy hacking.
@Googolplexed0 commented on GitHub (Aug 17, 2025):
Submitted a fix for this to the upstream library. Until it gets accepted pushed into the main release, this library will use my fork. Everything should work like before after updating Zotify to v0.9.21.
@nefariouslegion commented on GitHub (Aug 17, 2025):
Maybe I'm doing something wrong but I ran those commands and then tried to use Zotify. Still got errors.
@Googolplexed0 commented on GitHub (Aug 17, 2025):
You are still using the previous version v0.9.14, since
get_token()is callingsuper().get_token()in__init__.py. In v0.9.20,__init__.pyhas no functions. Make sure you update first.@nefariouslegion commented on GitHub (Aug 17, 2025):
Update what exactly? I ran those 2 commands and it said they were successful. Do I need to run them while in a specific directory?
@Googolplexed0 commented on GitHub (Aug 17, 2025):
Update Zotify. You have updated an upstream library that Zotify uses, but your older version of Zotify is not using the patched library correctly (it's overwriting some functions).
@nefariouslegion commented on GitHub (Aug 17, 2025):
Apologies because I'm probably being dumb. But I don't see the v0.9.20 update. It shows this as the most recent on the github
@Googolplexed0 commented on GitHub (Aug 17, 2025):
You're not dumb at all, I can see the source of your confusion.
These are just feature releases, or releases that I felt the need to write specific change notes for. I am going to make one for v0.9.20 shortly, I just haven't gotten around to that yet. Any change to the
mainbranch, shown here, is technically a new version. These changes will be made to your install after runningpipx install --force git+https://github.com/Googolplexed0/zotify.gitwhether there is an "official" release for it or not.@MianReplicate commented on GitHub (Aug 17, 2025):
Heyo so I'm having the same errors here as @nefariouslegion , but I can confirm that I have v0.9.20 as my console says this.
@qMvhmoud commented on GitHub (Aug 17, 2025):
Check my own version #50, It should work fine. I've tested it on two different devices.
@Googolplexed0 commented on GitHub (Aug 17, 2025):
You are indeed on v0.9.20, but I have just realized that there is a mistake in v0.9.20 that will use the un-forked library for pipx. Should be fixed with v0.9.21.
@jaynetics commented on GitHub (Aug 17, 2025):
thank you!
maybe helpful for others: if
pip uninstall librespot-pythonfails, as it did on my machine, using--forceto install the branch also works:@Aeiron2 commented on GitHub (Aug 18, 2025):
im still getting raise MercuryClient.MercuryException(response)
librespot.mercury.MercuryClient.MercuryException: status: 403
I updated librespot and downloaded the latest release. anyone know a fix?
@Aeiron2 commented on GitHub (Aug 18, 2025):
nvm i fixed it by replacing these 2 files
github.com/kokarare1212/librespot-python@7481dca654 (diff-3f04af0b3e)@TNAS123 commented on GitHub (Aug 18, 2025):
Unfortunately getting more errors with the latest version
AttributeError: 'NoneType' object has no attribute 'access_token'This is after updating Zotify and librespot-python. I may need to try downgrading as it was more reliable for playlist/list of entries in succession.
@ulyxie commented on GitHub (Aug 18, 2025):
Ditto on this.
The end of the log just repeats
DEBUG:Librespot:TokenProvider:Login5 token expired, need to re-authenticateso I don't know what the issue could be.zotify is version 0.9.22 installed from git repo, master branch, commit
e5d8fabviapipx install .(before I was installing with the -e parameter as well but that doesnt seem to be the issue). Im running this on Debian so pip is super limited on this system.Edit:
I fully forgot to add the command I'm running and the config that got generated from debug. Sorry! This could help with debugging
The command is the following:
config_DEBUG.json
zotify_DEBUG_2025-08-18_15-12-24.log
@RGPZ commented on GitHub (Aug 19, 2025):
@ulyxie I'm getting the error but only after a while of downloading a playlist since 'DEBUG:Librespot:TokenProvider:Login5 token expired, need to re-authenticate' says that the token expires, I assume that means the token used to sign in only lasts for a while before being reset. And I take it that the program doesn't know how to grab a new token after the original one has been reset until you restart the code.
@Googolplexed0 commented on GitHub (Aug 19, 2025):
This is likely the case. All tokens come with an expire time, so the function to renew the authentication must not be implemented correctly. I will look into this. At least it is working for single-token sessions!
@TNAS123 @ulyxie @RGPZ, this should be spun off into its own new issue since it's very different from the MercuryException 403 error. Since the 403 is solved, I'm going to close this issue.