[NodeJS] Pushing posts to Blogger from commandline

I was trying to write some small cli to push my posts to Blogger from the commandline. There are some tools out there, including googlecl and blogger-cli but no nodejs tool as far as I know. So, I registered to use Blogger API. Unfortunately, you'll have to wait 5 days just to get approval and instruction from Google, and that process is handled by only one man, Brett. So, while waiting for the API, here's my work around.

  1. From Google's code console, get your API key and stored it in ~/.bash_profile. Let's call it GOOGLE_API_KEY
  2. Head over to Blogger API sandbox and try some service that require authorization, e.g. inserting post. Note that you won't need this if you just want to get posts or comments or some actions that don't require authorization.
  3. Execute the service with the browser's console open. Watch in the Network tab for the post query
  4. In the query URL, look for key Bearer, then copy its value and store in ~/.bash_profile. Let's call it BLOGGER_TOKEN
  5. Also, get your blog's ID and save it in ~/.bash_profile as well. Let's call it BLOG_ID

Following is the simplified code snippet allows you to push your content to Blogger.

let nconf = require('nconf'),
    request = require('request');


let apiKey = nconf.get('GOOGLE_API_KEY'),
    bToken = nconf.get('BLOGGER_TOKEN'),
    bID = nconf.get('BLOG_ID'),
    bURI = '' + bID;
    url: bURI + '/posts?' + 
                'fetchBody=true' + 
                '&isDraft=true' + 
                '&key=' + apiKey,
    form: {
      labels: ['nodejs', 'sandbox'],
      title: 'Test CLI',
      content: 'This post was pushed from command line.'
    auth: { bearer: bToken }
  function(error, response) {
    if (!error) {
      console.log('Mission completed!', response.statusCode);
    else {
      throw error;

NOTE: the main problem with this approach is the bearer token expires after certain period of time


  1. looking for remote developer jobs? Take a look at

  2. Hai Author Good Information that i found here,do not stop sharing and Please keep updating us..... Thanks. Hire Nodejs Developers

  3. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Front end developer learn from Node JS Online Training from India . or learn thru Javascript Online Training from India. Nowadays JavaScript has tons of job opportunities on various vertical industry. ES6 Online Training

  4. Excellent post--I'm glad I found it.Thanks for sharing...
    node.js development services

  5. Thank you.Well it was nice post and very helpful information on AngularJS Online Training