Skip to content

Fix brand account support by adding X-Goog-AuthUser header - #127

Open
hamza-tm wants to merge 1 commit into
ccgauche:masterfrom
hamza-tm:fix/brand-account-x-goog-authuser-header
Open

hamza-tm wants to merge 1 commit into
ccgauche:masterfrom
hamza-tm:fix/brand-account-x-goog-authuser-header

Conversation

@hamza-tm

@hamza-tm hamza-tm commented Jan 6, 2026

Copy link
Copy Markdown

Hi, found an issue when using a brand account where no playlists would show up. Removing the account_id (i.e. going back to the main account) worked fine however.

After some digging it turns out we're missing a header. This PR just adds support for passing that header through. Have tested this locally and brand accounts work correctly for me now.

Summary

  • Fixes brand account playlists not showing up by adding the required X-Goog-AuthUser header to API requests
  • Adds auth_user field to YoutubeMusicInstance struct
  • Reads X-Goog-AuthUser from headers.txt in from_header_file()
  • Includes header in browse_raw and browse_continuation_raw API requests
  • Updates README with documentation for brand account setup

Test plan

  • Tested with brand account - playlists now load correctly
  • Verified backward compatibility - works without X-Goog-AuthUser header for non-brand accounts

Fixes #106

🤖 Generated with Claude Code

Brand accounts require the X-Goog-AuthUser header to be sent with API
requests. This change:

- Adds auth_user field to YoutubeMusicInstance struct
- Reads X-Goog-AuthUser from headers.txt in from_header_file()
- Includes X-Goog-AuthUser header in browse_raw and
  browse_continuation_raw API requests
- Updates README with documentation for brand account setup

Fixes ccgauche#106

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@ccgauche

Copy link
Copy Markdown
Owner

Thanks for the contribution. Just why aren't you just propagating the headers through the HeadMap further ?

Comment thread crates/ytpapi2/src/lib.rs
}
}
// Read x-goog-authuser from headers file
let headers_content = tokio::fs::read_to_string(path)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you are parsing the file again after having skipped the x-ggog-authuser but in reality you can just add a match case next to cookie and user-agent for it to be propagated.

@ccgauche

Copy link
Copy Markdown
Owner

I was pretty sure it was also supported and it is:

(Optional) Using a brand account

    If you use a second account for youtube music
        Go to https://myaccount.google.com/
        Switch to your brand account
        copy the number written in the url, after \b\
        paste it into a new account_id.txt file in the same folder as headers.txt
``

@restalex

Copy link
Copy Markdown
Contributor

I always used my branded account and I did not have any issue apart from refreshing the cookies sometimes.
I've tried this patch. In my case, nothing changes with or without the X-Goog-AuthUser as expected.
Maybe it is because my X-Goog-AuthUser. is 0. What its your value 0 or 1?
Have you tried without the X-Goog-AuthUser but with refreshed cookies?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cant see my playlists

3 participants