multi-scrobbler: YouTube Music auth fails after 30 minutes

Describe the bug This is more of an FYI report since it’s hardly a bug- more of an issue with YouTube Music authentication. I’ve noticed that the cookie seems to change with 30-60 minute intervals, whereas the scrobbler is no longer able to authenticate and fetch the play history.

Excerpt of the part of the cookie changing:

image

Doing a copy+paste of the new cookie to config.json makes the authentication work again for ~30 minutes.

The behaviour is the same regardless if using the browser to stream, 3:rd party desktop app or mobile app.

To Reproduce

  1. Multi-scrobbler (local) with ytmusic set up
  2. Play music for ~30 minutes

Expected behavior To have the session stay alive longer, I’m guessing that since I’m not logged out of any of the apps/browser that perhaps it’s some kind of token refresh causing the auth error in multi-scrobbler

Logs

[2024-06-13 14:11:55.840 +0200] ERROR  : [App] [Sources] [Ytmusic - MyYTMusic] Authentication test failed!
Error: Authentication test failed!
    at YTMusicSource.testAuth (file://CWD/src/backend/common/AbstractComponent.ts:1:2290)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async YTMusicSource.initialize (file://CWD/src/backend/common/AbstractComponent.ts:1:569)
    at async ScrobbleSources.addSource (file://CWD/src/backend/sources/ScrobbleSources.ts:4:2751)
    at async ScrobbleSources.buildSourcesFromConfig (file://CWD/src/backend/sources/ScrobbleSources.ts:4:352)
    at async file://CWD/src/backend/index.ts:1:2925
caused by: Error: Could not send the specified request to browse. Status code: 401
    at v.<anonymous> (CWD/node_modules/youtube-music-ts-api/build/exports.js:3:52363)
    at p (CWD/node_modules/youtube-music-ts-api/build/exports.js:3:43721)
    at Generator.<anonymous> (CWD/node_modules/youtube-music-ts-api/build/exports.js:3:45067)
    at Generator.next (CWD/node_modules/youtube-music-ts-api/build/exports.js:3:44150)
    at a (CWD/node_modules/youtube-music-ts-api/build/exports.js:3:50795)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[2024-06-13 14:11:55.839 +0200] ERROR  : [App] [Sources] [Ytmusic - MyYTMusic] Authentication failed with the given credentials. Verify your cookie and authUser are correct. | Error => Could not send the specified request to browse. Status code: 401
[2024-06-13 14:11:55.810 +0200] DEBUG  : [App] [Sources] [Ytmusic - MyYTMusic] Connection check was not required.
[2024-06-13 14:11:55.809 +0200] DEBUG  : [App] [Sources] [Ytmusic - MyYTMusic] No required data to build.
[2024-06-13 14:11:55.809 +0200] DEBUG  : [App] [Sources] [Ytmusic - MyYTMusic] Attempting to initia

Versions (please complete the following information):

  • multi-scrobbler: [e.g. 0.7.1 locally as a service using pm2, ytMusicDebug branch]

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (9 by maintainers)

Commits related to this issue

Most upvoted comments

The cookie updates and logging for these updates is in v0.8.3. There are also mentions of this issue in the FAQ and ytm source configuration docs. Since YTM is a blackbox I can’t do anything about YTM deciding to invalidate credentials other than explain the situation and point users back to refreshing their credentials manually.

If someone discovers a workaround for this I’m happy to revisit in the future.

Sorry for the late reply, weeks around Midsummer are always crazy busy.

I’ve not yet had the time to test this out but by the looks of it (thanks @SomeAspy) it seems that the issue persists, perhaps that’s one of the reasons behind https://ytmusicapi.readthedocs.io/ moving on to oauth.

Just before hitting busy times I actually collaborated on a Python script using the library mentioned above, being able to auth with oauth solved all the issues regarding auth and been running that little worker for around 2 weeks now without any issues.

So the idea of updating the TS library as well seems to me like the best route (but I 100% get it’s far out of scope for you/this project). If I have the time I might be able to take a look at it later.

Python script is just like a soggy band-aid compared to being able to use this, love the solution, hating that Google is making it so hard for no reason.

Was a long shot, but no such luck.

I am indeed using Firefox to pull cookies. Frustrating to see YouTube music being so hostile towards any sort if integrations. For what it’s worth, I wasn’t having these login issues when I originally wrote the blog post in March. Perhaps it’s worth trying to use 4675847fece6c9eea4c29dd35e3e726a5ec148a0 and see if these issues happen, so I’ll see what happens.