Permalink
Browse files

Use http request auth for get authentication

  • Loading branch information...
1 parent 9703b32 commit 0e6809695eb4bd7d4cc68b09d046b93ba123b8cd @hakovala committed Dec 16, 2012
Showing with 3 additions and 10 deletions.
  1. +3 −10 lib/trakt.js
View
13 lib/trakt.js
@@ -65,17 +65,10 @@ var getRequest = function (action, opts, options, callback) {
return callback(new Error('Missing parameters'));
}
- var request_body = '';
+ var request_options = Url.parse(url);
if (self.config.username && self.config.password) {
- request_body = JSON.stringify({
- username: self.config.username,
- password: self.config.password
- });
+ request_options.auth = self.config.username + ':' + self.config.password;
}
- var request_options = Url.parse(url);
- request_options.headers = {
- 'Content-Length': request_body.length
- };
var req = Http.request(request_options, function (res) {
res.setEncoding('utf8');
var result = '';
@@ -98,7 +91,7 @@ var getRequest = function (action, opts, options, callback) {
});
});
req.setTimeout(self.config.timeout);
- req.end(request_body);
+ req.end();
};
var postRequest = function (action, opts, options, callback) {

0 comments on commit 0e68096

Please sign in to comment.