Help How to generate cookie.json file for youtube? #392

Closed
opened 2025-11-09 09:48:17 -06:00 by GiteaMirror · 4 comments
Owner

Originally created by @nikunjgupta586 on GitHub (Aug 16, 2024).

problem description

Can someone tell me the steps to create cookie.json file for youtube? I mean How can I generate token from youtube and in which format should I store it into cookie.json file?

Originally created by @nikunjgupta586 on GitHub (Aug 16, 2024). ### problem description Can someone tell me the steps to create cookie.json file for youtube? I mean How can I generate token from youtube and in which format should I store it into cookie.json file?
GiteaMirror added the instance hosting help label 2025-11-09 09:48:17 -06:00
Author
Owner

@KwiatekMiki commented on GitHub (Aug 16, 2024):

Before doing this, make a new account just for cobalt and DO NOT use any of your accounts that you care about or can be linked back to you (for example with your recovery phone number/email). If you want to be extra safe, also use a VPN fpr making/logging into it.

First, you will need to clone cobalt and install everything needed for this. To do this, open a terminal/command prompt (i'll be referencing and run these commands (you can skip this if you're hosting your instance using node/npm):

git clone https://github.com/imputnet/cobalt
cd cobalt/api
npm install

When you're done with the above:

  1. Open an incognito browser tab
  2. Visit https://www.google.com/device
  3. Run npm run token:youtube in the same terminal as before
    (do cd cobalt/api if you already closed it or if you skipped the above)
  4. Log in with the account just for cobalt
  5. Follow the instructions.

You will get a token looking like this:

access_token=somestuff; refresh_token=morestuff; scope=https://www.googleapis.com/auth/youtube https://www.googleapis.com/auth/youtube-paid-content; token_type=Bearer; expiry_date=randomdateyoudontneedtocareabout

and put it in cookies.json like this:

{
    "youtube_oauth": [
        "access_token=somestuff; refresh_token=morestuff; ..."
    ]
}

If you want multiple cookies then put them in cookies.json like this:

{
  "youtube_oauth": [
    "your cookie from npm run token:youtube",
    "another cookie",
    "more cookies",
    "..."
  ]
}

Don't forget to restart your container after doing this!

@KwiatekMiki commented on GitHub (Aug 16, 2024): **Before doing this, make a new account just for cobalt and DO NOT use any of your accounts that you care about or can be linked back to you (for example with your recovery phone number/email). If you want to be extra safe, also use a VPN fpr making/logging into it.** First, you will need to clone cobalt and install everything needed for this. To do this, open a terminal/command prompt (i'll be referencing and run these commands (you can skip this if you're hosting your instance using node/npm): ``` git clone https://github.com/imputnet/cobalt cd cobalt/api npm install ``` When you're done with the above: 1. Open an incognito browser tab 2. Visit https://www.google.com/device 3. Run `npm run token:youtube` in the same terminal as before (do `cd cobalt/api` if you already closed it or if you skipped the above) 4. Log in with the account **just for cobalt** 5. Follow the instructions. You will get a token looking like this: > access_token=somestuff; refresh_token=morestuff; scope=https://www.googleapis.com/auth/youtube <https://www.googleapis.com/auth/youtube-paid-content>; token_type=Bearer; expiry_date=randomdateyoudontneedtocareabout and put it in cookies.json like this: ```json { "youtube_oauth": [ "access_token=somestuff; refresh_token=morestuff; ..." ] } ``` If you want multiple cookies then put them in cookies.json like this: ```json { "youtube_oauth": [ "your cookie from npm run token:youtube", "another cookie", "more cookies", "..." ] } ``` **Don't forget to restart your container after doing this!**
Author
Owner

@wukko commented on GitHub (Aug 16, 2024):

do NOT use your personal google account btw

@wukko commented on GitHub (Aug 16, 2024): do NOT use your personal google account btw
Author
Owner

@MHemelHasan commented on GitHub (Oct 19, 2024):

Hey @KwiatekMiki , If I didn't use docker an instance of clone the git repo and run from there then where should I create the cookies.json file,
in my repo, I found "cobalt\api\src\processing\cookie" and that cookie folder has a cookie.js and manager.js

I follow this instruction
Run npm run token:youtube in the same terminal as before
(do cd cobalt/api if you already closed it or if you skipped the above)
Log in with the account just for cobalt

generate the "youtube_oauth" but I couldn't put it in cookies.json because in my repo it doesn't have, And I didn't find any instruction where should I create or how to generate.

One more thing when I generate the youtube_oauth by running that commends "npm run token:youtube", and following the step it successfully generates it. It also has a cookie expiration time in my case that was 1 day meaning 24 hours. If so then it's really a problem if need to update the cookies every 24 hours.
Am I missing something or are there options that automatically update the cookie.json file

@MHemelHasan commented on GitHub (Oct 19, 2024): Hey @KwiatekMiki , If I didn't use docker an instance of clone the git repo and run from there then where should I create the cookies.json file, in my repo, I found "cobalt\api\src\processing\cookie" and that cookie folder has a cookie.js and manager.js I follow this instruction Run npm run token:youtube in the same terminal as before (do cd cobalt/api if you already closed it or if you skipped the above) Log in with the account just for cobalt generate the "youtube_oauth" but I couldn't put it in cookies.json because in my repo it doesn't have, And I didn't find any instruction where should I create or how to generate. One more thing when I generate the youtube_oauth by running that commends "npm run token:youtube", and following the step it successfully generates it. It also has a cookie expiration time in my case that was 1 day meaning 24 hours. If so then it's really a problem if need to update the cookies every 24 hours. Am I missing something or are there options that automatically update the cookie.json file
Author
Owner

@Haoran1272 commented on GitHub (Oct 28, 2024):

@MHemelHasan You need to configure the path to the cookies.json in .env file, like "COOKIE_PATH = /www/cobalt/api/cookies.json".

@Haoran1272 commented on GitHub (Oct 28, 2024): @MHemelHasan You need to configure the path to the cookies.json in .env file, like "COOKIE_PATH = /www/cobalt/api/cookies.json".
Sign in to join this conversation.