initial commit

This commit is contained in:
Dan Zajdband
2012-05-16 20:32:25 -03:00
commit a951072182
8 changed files with 268 additions and 0 deletions

25
lib/auth.js Normal file
View File

@@ -0,0 +1,25 @@
/**
* Module dependencies
*/
var request = require('superagent')
, endpoints = require('./endpoints.json')
, MovieDB = module.parent.exports;
MovieDB.prototype.requestToken = function(fn){
var that = this;
request
.get(endpoints.base_url + endpoints.authentication.requestToken)
.send({api_key: that.api_key})
.set('Accept', 'application/json')
.end(function(res){
if(res.ok) that.token = res.body;
else throw new Error('Invalid authentication');
fn();
});
};