Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'master' of https://github.com/icodeforlove/everyauth in…
…to icodeforlove-master

Conflicts:
	lib/modules/tumblr.js
  • Loading branch information
bnoguchi committed Oct 16, 2012
2 parents 5d36864 + e97a4f7 commit 8d1eb48
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions lib/modules/tumblr.js
@@ -1,30 +1,25 @@
var oauthModule = require('./oauth')
, Parser = require('xml2js').Parser
, url = require('url');

var tumblr = module.exports =
oauthModule.submodule('tumblr')
.apiHost('http://www.tumblr.com/api')
.apiHost('http://api.tumblr.com/v2')
.oauthHost('http://www.tumblr.com')
.entryPath('/auth/tumblr')
.callbackPath('/auth/tumblr/callback')
.sendCallbackWithAuthorize(false)
.fetchOAuthUser( function (accessToken, accessTokenSecret, params) {
var promise = this.Promise();
this.oauth.get(this.apiHost() + '/authenticate', accessToken, accessTokenSecret, function (err, data) {
this.oauth.get(this.apiHost() + '/user/info', accessToken, accessTokenSecret, function (err, data) {
if (err) return promise.fail(err);
var parser = new Parser();
parser.on('end', function (result) {
var oauthUser;
if(result.tumblelog instanceof Array){
oauthUser = result.tumblelog[0]['@'];
} else {
oauthUser = result.tumblelog['@'];
}
promise.fulfill(oauthUser);
});
parser.parseString(data);
try {
data = JSON.parse(data);
promise.fulfill(data.response.user);
} catch (e) {
promise.fail(e);
}
});

return promise;
})
.authCallbackDidErr( function (req) {
Expand Down

0 comments on commit 8d1eb48

Please sign in to comment.