Skip to content

Instantly share code, notes, and snippets.

@thelebster
Forked from SunboX/basic-http-auth-node.js
Created May 1, 2023 19:02
Show Gist options
  • Save thelebster/939f265da7e4ae42361139ae7e13e3ed to your computer and use it in GitHub Desktop.
Save thelebster/939f265da7e4ae42361139ae7e13e3ed to your computer and use it in GitHub Desktop.
Basic HTTP Authorization Header in Node.js
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
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment