Skip to content

Instantly share code, notes, and snippets.

@fiznool
Created December 18, 2014 08:19
Show Gist options
  • Save fiznool/8078ed5cd3b6357235c2 to your computer and use it in GitHub Desktop.
Save fiznool/8078ed5cd3b6357235c2 to your computer and use it in GitHub Desktop.
request basic auth
var request = require('request');
// The `auth` object will take precedence
// over the `Authorization` header
var options = {
url: 'http://requestb.in/1jt9nmk1',
method: 'GET',
headers: {
Authorization: 'Basic 1234'
},
auth: {
username: 'user',
password: 'pass'
}
};
request(options, function(error, response, body) {
if (!error) {
console.log(body);
}
});
HEADERS
Host: requestb.in
X-Request-Id: b6f8fcac-f463-41fc-ab6d-b404f1b5beef
Authorization: Basic dXNlcjpwYXNz
Via: 1.1 vegur
Connection: close
Total-Route-Time: 0
Connect-Time: 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment