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

Fix account_index #736

Closed
wants to merge 1 commit into from
Closed

Conversation

dnicolson
Copy link
Contributor

@dnicolson dnicolson commented Aug 18, 2024

This fixes #735.

The X-Goog-PageId header determines the active account, not the X-Goog-Authuser header. Data sync IDs come from the /getDatasyncIdsEndpoint endpoint and are saved in local storage.

The prettyPrint and alt parameters need to be removed to prevent this response to /playlist requests:

)]}'
{"reload":"now"}

Here are examples of data sync IDs for the number of accounts signed in.

Three accounts:
id_1||id_2::yt-player::yt-player-lv
id_0||::yt-player::yt-player-lv

Two accounts:
id_1||id_0::yt-player::yt-player-lv
id_0||::yt-player::yt-player-lv

One account:
id_0||::yt-player::yt-player-lv

@absidue
Copy link
Collaborator

absidue commented Aug 18, 2024

This pull request seems to assume that every user of the library is only using it directly on YouTube's own website and this will blow up for everyone that doesn't (which is probably most users).

A better approach would be to add an extra parameter so the session creation so you can pass the relevant parameters into the library, the same way that visitor data and poToken's are handled.

@dnicolson
Copy link
Contributor Author

dnicolson commented Aug 18, 2024

The changes only apply if the cookie is set, and this only works in the browser not true #707 (comment):
https://github.com/LuanRT/YouTube.js/blob/4942992/src/utils/HTTPClient.ts#L140

Are you suggesting limiting the changes to accepting a data sync ID and setting the X-Goog-PageId header? In that case, the account_index option would need to be removed entirely.

@dnicolson
Copy link
Contributor Author

I added a client_name check to make the intent clearer.

@absidue
Copy link
Collaborator

absidue commented Aug 18, 2024

Are you suggesting limiting the changes to accepting a data sync ID and setting the X-Goog-PageId header?

Better that it breaking for people passing cookies to YouTube.js on Node, Deno or React Native or people using it in web browsers but not on the YouTube website.

@dnicolson
Copy link
Contributor Author

It should be more robust now, the only risks I see are:

  • Only the web client will get the X-Goog-AuthUser header, which didn't appear to work previously.
  • Other websites will not have additional URL search parameters.

Works with the web client and in Node.js.

@dnicolson dnicolson closed this Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The account_index parameter does not work
2 participants