Syncing social media account to an existing user account?

Does anyone knows here a good package to use (with documentation) that can link social media accounts to an existing user account on our meteor app?

Thanks in advance.

Just to clarify, are you asking about linking social media accounts for use in OAuth? Or just capturing a reference to the user’s social media page(s)?

If its the latter, you can just add in a reference to the social media page in the user schema. If its the former, then there used to be a package for account merging that worked with Meteor 1.3. When upgrading Meteor, I did not find a replacement package so I tied into the account create hook to manually merge them then. If this is what you are after, I can send you the link to a post that helped me accomplish this.

I’m going to be moving a project from accounts-password only to password + social media accounts shortly, and account merging is going to be a part of that. A link to that post would be super appreciated!

Sure, this is the post that helped me:

And if you want to see how I did it, here is the basic idea from my server/main.js (my Meteor app supports password, facebook, and google auth):

Meteor.startup(() => {

	Accounts.onCreateUser((options, user) => {
		let existingUser = Meteor.user();
		let email;
		let firstName;
		let lastName;
		let service;

		if (user.services.facebook) {
			firstName = user.services.facebook.first_name;
			lastName = user.services.facebook.last_name;
			email = user.services.facebook.email;
			service = 'facebook';
		} else if (user.services.google) {
			firstName = user.services.google.given_name;
			lastName = user.services.google.family_name;
			email = user.services.google.email;
			service = 'google';
		} else {
			firstName = EMPTY_VAL;
			lastName = EMPTY_VAL;
			email = options.email;
			service = 'password';
			verified = false;
		}

		if (!existingUser) existingUser = Meteor.users.findOne({ email });

		if (existingUser) {
			existingUser.services = existingUser.services || {};
			existingUser.services[service] = user.services[service];
			Meteor.users.remove({ _id: existingUser._id });
			user = existingUser;
		}

		...any additional logic...

		return user;
	});

});
2 Likes

This is great - many thanks!

Is any out of the box package it will allow to have the same user with different type of authentications?

The default system is just creates a new user for each type.