-
Notifications
You must be signed in to change notification settings - Fork 1
How to obtain Cookie
(15 November 2024)
YouTube has limited OAuth login to TV clients. The effect is that, after linking YouTube to our app via Device Code, attempts to fetch web content will return HTTP 400 Bad Request errors. See, for example, LuanRT/YouTube.js#803 and yt-dlp/yt-dlp#11462.
To access account-specific content, users can still pass cookies from the web browser. A cookie is a string value that keeps track of the user's YouTube session in the browser.
(Firefox was used for illustration, but you should be able to do it on other modern desktop browsers too)
For longer-lasting cookies, it is recommended that you do the following in a fresh, private browsing session. After obtaining the cookie, close the private browser immediately (but do not sign out of YouTube).
- In a browser, sign into YouTube (or YouTube Music, doesn't matter), then hit F12 to bring up the Developer Tools.
- Choose the Network tab.
- Select XHR filter.
- Enter 'browse' in the Filter box.
- Now scroll down the YouTube web page until an entry starting with 'browse' appears. Select it.
- Scroll down in the Headers tab until you see Cookie under Request Headers.
- Right-click on the value of Cookie and select Copy Value.
- The cookie has been placed in your clipboard and can be passed to the app. It will remain valid until you sign out or YouTube expires it. Do not reveal the cookie to anyone!