Search code examples
facebooktwittermeteorgoogle-plusaccounts

Connecting social Networks using Meteor Login Services without Logging in


I want to connect social Networks like Twitter, Google+, Pinterest without logging in - only connecting and saving the access Token and the data in user.services, but using the meteor accounts packages like accounts-facebook or accounts-twitter. For better understanding, at the moment im using accounts-facebook to log the user in, but don´t want to log the user in to another profile or give him the possibility to use another network than facebook to log in.

Anyone any idea how this could work, or how to only trigger the "create accessToken and save data" process?


Solution

  • I just tested this and it works. You'll want to inspect the options object - it has many properties that may contain the data you need:

    Accounts.validateLoginAttempt(function(options){
        if (options.type === 'facebook'){
            console.log('Facebook login ok!');
            return true;  // allow login
        } else {
            // Do something else with options here
    
            // Don't allow login
            console.log(options.type + ' login not allowed!');
            return false;
        }
    });