Skip to content

"Authentication Failed" when pasting request headers from Chrome #857

@apastel

Description

@apastel
  • I confirm that I have read the FAQ

Describe the bug

When pasting request headers from Chrome (even though Firefox is recommended), the authentication process fails with:

ytmusicapi.exceptions.YTMusicUserError: The following entries are missing in your headers: x-goog-authuser. Please try a different request (such as /browse) and make sure you are logged in.

The reason this happens is because starting sometime early last year, Chrome request headers are copied to your clipboard without a colon at the end of each key. For example:

accept
*/*
accept-encoding
gzip, deflate, br, zstd
accept-language
en-US,en;q=0.9

This breaks the parser in browser.py:setup_browser.

I've been working on a solution but it's a bit tricky since now the header keys and header values don't have any distinguishing characteristics from each other -- you kind of just have to assume the first line is a key and the 2nd line is a value and go from there.

References:

We could port over that fix to ytmusicapi but I'm not super proud of it. I would rather start with the existing fix that uses chrome_remembered_key and modify that instead. I started to work on something but so far it's not quite working yet.

ytmusicapi version

1.11.4

To Reproduce

Steps to reproduce the behavior:

  1. Follow instructions to paste request headers, use Chrome instead of Firefox
  2. Observe error in terminal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions