1

I have a meteor app, with packages :

useraccounts:bootstrap; 
service-configuration; 
accounts-facebook; 

The facebook side was configured to allow requests from localhost. When using the register/signin with facebook from the atForm, a popup appears

EDIT

The popup is actually not empty but displays a message 'login complete, click to close' but closed fast because that's how I configured it on the facebook side.

And the console logs an error:

Exception while invoking method 'login' undefined

EDIT

Here is the service conf:

ServiceConfiguration.configurations.remove({
    service: 'facebook'
});
ServiceConfiguration.configurations.insert({
    service: 'facebook',
    appId: 'removed',
    secret: 'removed'
});

EDIT

Here is the client side code :

Template.atForm.events({
    'click #at-facebook': function(event) {
        console.log("facebook click");
        Meteor.loginWithFacebook({
          requestPermissions: ['email', 'user_friends']
          }, function (err) {
          if (err)
            Session.set('errorMessage', err.reason || 'Unknown error');
        });
    }
});

EDIT When registering with facebook the user created is as follow :

{ createdAt: Thu Jan 21 2016 16:00:08 GMT+0100 (CET),
I20160121-16:00:08.108(1)?   _id: 'Kgs3WswMdB9hsxMfp',
I20160121-16:00:08.108(1)?   services: 
I20160121-16:00:08.108(1)?    { facebook: 
I20160121-16:00:08.108(1)?       { accessToken: 'removed',
I20160121-16:00:08.108(1)?         expiresAt: 1458562023670,
I20160121-16:00:08.109(1)?         id: 'removed',
I20160121-16:00:08.109(1)?         email: 'removed',
I20160121-16:00:08.109(1)?         name: 'Mathieu Kudla',
I20160121-16:00:08.109(1)?         first_name: 'Mathieu',
I20160121-16:00:08.110(1)?         last_name: 'Kudla',
I20160121-16:00:08.110(1)?         link: 'https://www.facebook.com/app_scoped_user_id/removed/',
I20160121-16:00:08.110(1)?         gender: 'male',
I20160121-16:00:08.110(1)?         locale: 'fr_FR',
I20160121-16:00:08.110(1)?         age_range: [Object] } } }

This seems to indicate that the facebook handshake was successful?

What is causing that error? Thanks :)

Mathieu K.
  • 903
  • 8
  • 27
  • Can you post some of your code? Both the facebook login client side code and your server side service configuration code. – Brett McLain Jan 21 '16 at 14:37
  • Just edited to include that. Thanks for your time. – Mathieu K. Jan 21 '16 at 14:45
  • Thanks those details help; do you have any logs on the server side, or do you only get the message "Exception while invoking method 'login' undefined" on the client side? – Brett McLain Jan 21 '16 at 14:48
  • Also, do you use any kind of schema for mongo that would require certain fields to be set on the user profile? Also try adding this code on the server side: Accounts.onCreateUser(function(options, user) { console.log(user); return user; }); – Brett McLain Jan 21 '16 at 14:55
  • That's all I got, which is part of the problem, I don't event know what is throwing the error... – Mathieu K. Jan 21 '16 at 14:57
  • I just did that and edited in the results. This seem to indicate that the error is not thrown by fb? No schema on the users collection btw. – Mathieu K. Jan 21 '16 at 15:04

1 Answers1

0

Ok I kinda solved it.

I digged in the log-in attempts and noticed that the oauth service was not properly paired with the user. I don't know why that is or if there is a better solve but I added the line :

if (user.services) { var service = _.pairs(user.services)[0]; }

to my onCreateUser hook and appended the user object properly before returning it. It seems to have done the trick but I don't know what I was not doing properly the first time...

Mathieu K.
  • 903
  • 8
  • 27