Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of https://github.com/icodeforlove/everyauth in…

…to icodeforlove-master

Conflicts:
	lib/modules/tumblr.js
  • Loading branch information...
commit 8d1eb48703891eb29d654585d67d63a7b394554a 2 parents 5d36864 + e97a4f7
@bnoguchi authored
Showing with 9 additions and 14 deletions.
  1. +9 −14 lib/modules/tumblr.js
View
23 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) {
Please sign in to comment.
Something went wrong with that request. Please try again.