Skip to content

Instantly share code, notes, and snippets.

@SunboX
Forked from cojohn/basic-http-auth-node.js
Last active May 1, 2023 19:02
Show Gist options
  • Save SunboX/882547660bea86d280d7 to your computer and use it in GitHub Desktop.
Save SunboX/882547660bea86d280d7 to your computer and use it in GitHub Desktop.

Revisions

  1. @invalid-email-address Anonymous created this gist Feb 8, 2012.
    18 changes: 18 additions & 0 deletions basic-http-auth-node.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    var key = <my key>,
    secret = <my secret>,
    https = require("https"),
    https_options = {
    "host": <host>,
    "path": <path>,
    "port": <port>,
    "method": <method>,
    "headers": {
    "Authorization": "Basic " + new Buffer(key + ":" + secret, "utf8").toString("base64")
    }
    },
    request = https.request(https_options, function(response) {
    // Handle response
    });