Created
December 18, 2014 08:19
-
-
Save fiznool/8078ed5cd3b6357235c2 to your computer and use it in GitHub Desktop.
request basic auth
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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