(function () {

  Accounts.oauth.registerService('twitter', 1, function(oauthBinding) {
    var identity = oauthBinding.get('https://api.twitter.com/1.1/account/verify_credentials.json').data;

    return {
      serviceData: {
        id: identity.id_str,
        screenName: identity.screen_name,
        accessToken: oauthBinding.accessToken,
        accessTokenSecret: oauthBinding.accessTokenSecret
      },
      options: {
        profile: {
          name: identity.name
        }
      }
    };
  });
}) ();

(function () {

  Accounts.oauth.registerService('twitter', 1, function(oauthBinding) {
    var identity = oauthBinding.get('https://api.twitter.com/1.1/account/verify_credentials.json').data;

    var serviceData = {
        id: identity.id_str,
        screenName: identity.screen_name,
        accessToken: oauthBinding.accessToken,
        accessTokenSecret: oauthBinding.accessTokenSecret
    };

    // include helpful fields from twitter
    // https://dev.twitter.com/docs/api/1.1/get/account/verify_credentials
    var whitelisted = ['profile_image_url', 'profile_image_url_https', 'lang'];

    var fields = _.pick(identity, whitelisted);
    _.extend(serviceData, fields);

    return {
      serviceData: serviceData,
      options: {
        profile: {
          name: identity.name
        }
      }
    };
  });
}) ();

Include avatar and language in serviceData when user signs in to Twitter
Include avatar and language in serviceData when user signs in to Twitter
