-
Notifications
You must be signed in to change notification settings - Fork 0
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
Musixmatch token persistence #10
Comments
Hello @Eimaen! I have another question. Are there any errors or cases when I need to regenerate the token? Maybe some exception is thrown during the authentication stage? Or we can forget about this case and reuse the generated token when launching the application? |
To check if the token is still valid, you can try searching for song ( Edt: there is auth, but it's "Bearer" token only, so removed the first sentence to eliminate inaccuracies |
Sure, glad to help! |
#10 Added MemoryCache for token in MusixmatchProvider
Hi, @skuill! I really like your repository, as it provides an extensive and reliable way to retrieve texts from different sources simultaneously. Great job!
As a maintainer of MusixmatchClientLib, I'm always interested in how the library is used, and want to point out some nuances of its usage in your project. It's a suggestion, so feel free to just close the issue tho.
In your code, MusixmatchClient is initialized using new instance of MusixmatchToken, which is completely fine for generating "Desktop" context token (ref: code). However, users might stumble upon rate limits from Musixmatch API, as there's a major cooldown on token generation endpoint. After multiple tests I determined, that tokens with "Desktop" context don't expire automatically at all, so it's worth saving it somewhere on the client side and reusing it when creating a new
MusixmatchToken
instance (by passing it directly into theMusixmatchToken
constructor:new MusixmatchToken(yourSavedToken)
). I'm not sure if you save it, but looks like the token's generated every time theMusixmatchClient GetMusixmatchClient()
is called.According to the comments to the referenced method, library works as expected, as it's not designed to be used with official mxm API. I'll walk along the token generation pipeline from the official Musixmatch application to make it clear (hope this doesn't add too much to the issue).
Once one starts the official application, a new token is generated *and saved (the algorithm of token generation is already reverse-engineered, it's what the constructor of
MusixmatchToken
does). This token is able to do pretty much everything you need (it can fetch lyrics, fetch synced lyrics and search for songs). As the app receives token, it attempts to authenticate the user by giving them an external OAuth link (you can generate a similar link usingmusixmatchTokenInstance.GetAuthUrl()
), that allows user to upload and sync lyrics, but requires Musixmatch account to operate.Hope it helps debugging failed
MusixmatchProvider
tests (if they do fail).Have a wonderful day!
Eimaen
The text was updated successfully, but these errors were encountered: