From b41ec0b194d0b9491e350981fdc1557e15aea742 Mon Sep 17 00:00:00 2001 From: slickplaid Date: Fri, 24 Jun 2011 06:47:05 -0500 Subject: [PATCH] Added Vimeo OAuth Module. --- lib/modules/vimeo.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 lib/modules/vimeo.js diff --git a/lib/modules/vimeo.js b/lib/modules/vimeo.js new file mode 100644 index 00000000..498c108f --- /dev/null +++ b/lib/modules/vimeo.js @@ -0,0 +1,35 @@ +var oauthModule = require('./oauth') + , OAuth = require('oauth').OAuth; + +var vimeo = module.exports = +oauthModule.submodule('vimeo') + .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://vimeo.com/api/rest/v2') + .oauthHost('http://vimeo.com') + + .requestTokenPath('/oauth/request_token') + .authorizePath('/oauth/authorize') + .accessTokenPath('/oauth/access_token') + + .entryPath('/auth/vimeo') + .callbackPath('/auth/vimeo/callback') + + .fetchOAuthUser( function (accessToken, accessTokenSecret, params) { + var promise = this.Promise(); + console.log(params, accessToken, accessTokenSecret); + this.oauth.get(this.apiHost() + '?format=json&method=vimeo.people.getInfo&user_id=' + accessTokenSecret, accessToken, accessTokenSecret, function (err, data) { + if (err) return promise.fail(err); + var oauthUser = JSON.parse(data.person); + return promise.fulfill(oauthUser); + }); + return promise; + });