mirror of
https://github.com/KevinMidboe/moviedb.git
synced 2025-12-28 21:01:03 +00:00
initial commit
This commit is contained in:
25
lib/auth.js
Normal file
25
lib/auth.js
Normal 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();
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user