Search code examples
meteormeteor-accounts

In Discover Meteor, how do I access the "author" username if using accounts-twitter?


I'm working through Discover Meteor and am using accounts-twitter instead of accounts-password.

When adding posts, author is set using user.username but this doesn't work with accounts-twitter.

How do I access the Twitter handle to set the author?

I've tried user.services.twitter.screenName but this does nothing.


Solution

  • Turns out the issue is related to publications.

    Be sure to include the following in order to access Twitter profile info in the client.

    On the server:

    Meteor.publish("userData", function () {
    return Meteor.users.find({_id: this.userId},
        {fields: {'services.twitter': 1}});
    });
    

    And, in the client:

    Meteor.subscribe('userData');