# Browser Authentication Setup This guide will help you extract the necessary authentication cookies from your browser to use with `ytmusicapi`. ## Step 1: Open YouTube Music 1. Open your browser (Chrome or Firefox) 2. Navigate to [https://music.youtube.com](https://music.youtube.com) 3. **Make sure you are logged in** to your Google account ## Step 2: Open Developer Tools - **Chrome/Edge:** Press `F12` or `Ctrl+Shift+I` (Windows/Linux) / `Cmd+Option+I` (Mac) - **Firefox:** Press `F12` or `Ctrl+Shift+I` (Windows/Linux) / `Cmd+Option+I` (Mac) ## Step 3: Go to Network Tab 1. Click on the **"Network"** tab in Developer Tools 2. If you don't see it, look for it in the tabs at the top of the developer tools panel ## Step 4: Capture Network Requests 1. **Refresh the page** (press `F5` or `Ctrl+R` / `Cmd+R`) 2. Wait for the page to load completely 3. Look for requests to `music.youtube.com` in the network list ## Step 5: Find the Right Request 1. Click on any request that goes to `music.youtube.com` 2. Look for requests like: - `browse` - `getBrowse` - `search` - Or any request that shows `music.youtube.com` in the URL ## Step 6: Copy Headers 1. With a request selected, click on the **"Headers"** tab 2. Scroll down to **"Request Headers"** section 3. You need to copy the following headers: ### Required Headers: - **Cookie** - A long string starting with something like `VISITOR_INFO1_LIVE=...` - **User-Agent** - Something like `Mozilla/5.0 (Windows NT 10.0; Win64; x64)...` ### Optional but Recommended: - **X-Goog-AuthUser** - Usually `0` or `1` - **Accept** - Usually `*/*` or `application/json` - **Accept-Language** - Your language preference - **Content-Type** - Usually `application/json` - **x-origin** - Usually `https://music.youtube.com` ## Step 7: Create browser.json Create a file named `browser.json` in this directory with the following structure: ```json { "User-Agent": "PASTE_YOUR_USER_AGENT_HERE", "Accept": "*/*", "Accept-Language": "en-US,en;q=0.9", "Content-Type": "application/json", "X-Goog-AuthUser": "0", "x-origin": "https://music.youtube.com", "Cookie": "PASTE_YOUR_COOKIE_HERE" } ``` Replace: - `PASTE_YOUR_USER_AGENT_HERE` with the User-Agent header value you copied - `PASTE_YOUR_COOKIE_HERE` with the Cookie header value you copied **Important:** The Cookie value is very long and contains sensitive information. Keep this file private and never commit it to version control. ## Step 8: Verify Your `browser.json` should look something like this (with your actual values): ```json { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36", "Accept": "*/*", "Accept-Language": "en-US,en;q=0.9", "Content-Type": "application/json", "X-Goog-AuthUser": "0", "x-origin": "https://music.youtube.com", "Cookie": "VISITOR_INFO1_LIVE=abc123...; YSC=xyz789...; [many more cookie values]" } ``` ## Troubleshooting - **Can't find the Cookie header?** Make sure you're looking at a request to `music.youtube.com`, not `youtube.com` - **Authentication fails?** Your cookies may have expired. Repeat the process to get fresh cookies - **Still having issues?** Try using a different request from the network tab, or refresh the page and try again ## Security Note The `browser.json` file contains your authentication cookies. Anyone with access to this file can access your YouTube Music account. Keep it secure and never share it publicly.