DevOps Zone is brought to you in partnership with:

Santiago has posted 2 posts at DZone. You can read more from them at their website. View Full User Profile

Node.js Call https with BASIC Authentication

  • submit to reddit

Node.js https module used to make a remote call to a remote server using https and BASIC authentication:

var options = {
   host: '',
   port: 443,
   path: '/api/service/'+servicename,
   // authentication headers
   headers: {
      'Authorization': 'Basic ' + new Buffer(username + ':' + passw).toString('base64')

//this is the call
request = https.get(options, function(res){
   var body = "";
   res.on('data', function(data) {
      body += data;
   res.on('end', function() {
    //here we have the full response, html or json object
   res.on('error', function(e) {
      onsole.log("Got error: " + e.message);

Published at DZone with permission of its author, Santiago Urrizola.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)