Youtube API on (process.env.VARIABLE)


I was planning to use youtube API on my discord bot to make my bot cooler. I wonder if supports youtube API? The youtube API can be installed using Node.js (which I plan to do).

So I’m looking at the most basic sample code. However, I’m not familiar with:

  • process.env variables (I don’t have the value for process.env.HOME, process.env.HOMEPATH and process.evn.USERPROFILE + ‘/.credentials’)
  • I’m not even sure if I need to manually modify the {key-symbol}.env file in my glitch project. However the sample code uses the following:
    var TOKEN_DIR = (process.env.HOME || process.env.HOMEPATH ||
        process.env.USERPROFILE) + '/.credentials/';
    var TOKEN_PATH = TOKEN_DIR + 'youtube-nodejs-quickstart.json';


What they’re saying there is basically this: Let’s figure out where our token might be. We’ll look for a path in the HOME, HOMEPATH, or USERPROFILE environment variables and then add /.credentials/ to it and look in there for our token file.

In your Glitch project’s console, of you open the console and type printenv you’ll get a listing of all of the environment variables, and by default you should see HOME=/app which Node will see when it looks for process.env.HOME, so if you add a file called .credentials/youtube-nodejs-quickstart.json and put your token information in it that part of the sample code should work as is.