findOrCreateUser returning undefined user for tumblr? #244

Open
gonzoramos opened this Issue Apr 19, 2012 · 1 comment

Comments

Projects
None yet
2 participants
@gonzoramos

Hi,

I am pretty new with everyauth, and I am blocked by a possible error / bug / silly thing on my part. I follow all of the instructions I can find but I have not been able to succesfully use the module to authenticate with tumblr. The key part that fails is:

everyauth.tumblr
  .consumerKey('mykey')
  .consumerSecret('mysecret')
  .findOrCreateUser( function (session, accessToken, accessSecret, tumblrUser) {
    return usersByTumblrName[tumblrUser.name] ||
      (usersByTumblrName[tumblrUser.name] = addUser('tumblr', tumblrUser));
  })
  .redirectPath('/');

where tumblrUser returns as 'undefined'. I even tried the example and it fails there as well...

/Users/gonzalo/Documents/Github/misc/prototypes/gonzalo-sites/myfeed/node_modules/everyauth/lib/modules/everymodule.js:348
  throw err;
        ^
TypeError: Cannot read property 'name' of undefined
    at Object._findOrCreateUser (/Users/gonzalo/Documents/Github/misc/prototypes/gonzalo-sites/myfeed/node_modules/everyauth/example/server.js:296:40)
    at Object.exec (/Users/gonzalo/Documents/Github/misc/prototypes/gonzalo-sites/myfeed/node_modules/everyauth/lib/step.js:47:21)
    at /Users/gonzalo/Documents/Github/misc/prototypes/gonzalo-sites/myfeed/node_modules/everyauth/lib/stepSequence.js:26:38
    at [object Object].fulfill (/Users/gonzalo/Documents/Github/misc/prototypes/gonzalo-sites/myfeed/node_modules/everyauth/lib/promise.js:42:25)
    at /Users/gonzalo/Documents/Github/misc/prototypes/gonzalo-sites/myfeed/node_modules/everyauth/lib/stepSequence.js:29:23
    at [object Object].fulfill (/Users/gonzalo/Documents/Github/misc/prototypes/gonzalo-sites/myfeed/node_modules/everyauth/lib/promise.js:42:25)
    at Parser.<anonymous> (/Users/gonzalo/Documents/Github/misc/prototypes/gonzalo-sites/myfeed/node_modules/everyauth/lib/modules/tumblr.js:18:17)
    at Parser.emit (events.js:67:17)
    at Object.onclosetag (/Users/gonzalo/Documents/Github/misc/prototypes/gonzalo-sites/myfeed/node_modules/everyauth/node_modules/xml2js/lib/xml2js.js:120:24)
    at emit (/Users/gonzalo/Documents/Github/misc/prototypes/gonzalo-sites/myfeed/node_modules/everyauth/node_modules/xml2js/node_modules/sax/lib/sax.js:322:32)

Any help would be greatly appreciated!
-G

@philippkueng

This comment has been minimized.

Show comment
Hide comment
@philippkueng

philippkueng May 11, 2012

Contributor

Hi @gonzoramos,

Do you happen to have multiple tumblr-blogs registered with your username?

In that case the error is within /lib/modules/tumblr.js on line 17. (https://github.com/bnoguchi/everyauth/blob/master/lib/modules/tumblr.js).
Because tumblr is returning an XML response with multiple tumblelog entries those get converted into a JS array by xml2js. With the current implementation however result.tumblelog get's treated as single object which results in the object being undefined and therefore having no .name property.

If you only have one tumblelog registered i'd be nice to have a look at your XML response, to get it put console.log(data); on line 14 of tumblr.js.

Contributor

philippkueng commented May 11, 2012

Hi @gonzoramos,

Do you happen to have multiple tumblr-blogs registered with your username?

In that case the error is within /lib/modules/tumblr.js on line 17. (https://github.com/bnoguchi/everyauth/blob/master/lib/modules/tumblr.js).
Because tumblr is returning an XML response with multiple tumblelog entries those get converted into a JS array by xml2js. With the current implementation however result.tumblelog get's treated as single object which results in the object being undefined and therefore having no .name property.

If you only have one tumblelog registered i'd be nice to have a look at your XML response, to get it put console.log(data); on line 14 of tumblr.js.

philippkueng added a commit to philippkueng/everyauth that referenced this issue May 11, 2012

fix for issue #244 where the tumblr module is returning an undefined …
…user when there are multiple tumblelogs associated to the account.

bnoguchi added a commit that referenced this issue Aug 8, 2012

Merge pull request #261 from philippkueng/patch-1
fix for issue #244 where the tumblr module is returning an undefined user when there are multiple tumblelogs associated to the account.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment