Skip to content

Commit

Permalink
Merge branch 'justin.tv'
Browse files Browse the repository at this point in the history
  • Loading branch information
slickplaid committed Jun 24, 2011
2 parents fbef0e3 + a72b152 commit b900e69
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions lib/modules/justintv.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
var oauthModule = require('./oauth')
, OAuth = require('oauth').OAuth;

var inspect = require('util').inspect, fs = require('fs');

var justintv = module.exports =
oauthModule.submodule('justintv')
.definit( function () {
this.oauth = new OAuth(
this.oauthHost() + this.requestTokenPath()
, this.oauthHost() + this.accessTokenPath()
, this.consumerKey()
, this.consumerSecret()
, '1.0', null, 'HMAC-SHA1', null
);
})

.apiHost('http://api.justin.tv')
.oauthHost('http://api.justin.tv')

.requestTokenPath('/oauth/request_token')
.authorizePath('/oauth/authorize')
.accessTokenPath('/oauth/access_token')

.entryPath('/auth/justintv')
.callbackPath('/auth/justintv/callback')

.fetchOAuthUser( function (accessToken, accessTokenSecret, params) {
var promise = this.Promise();
console.log(params, accessToken, accessTokenSecret);
this.oauth.get(this.apiHost() + '/api/account/whoami.json', accessToken, accessTokenSecret, function (err, data) {
if (err) return promise.fail(err);
var oauthUser = JSON.parse(data);
return promise.fulfill(oauthUser);
});
return promise;
});

0 comments on commit b900e69

Please sign in to comment.