Search code examples
facebookauthenticationmeteorreactjsmeteor-accounts

Meteor + facebook login (loginWithFacebook) issue. client_id is always undefined in login popup's URL


I put this issue in gist as well: https://gist.github.com/yhagio/7561f34d12bc5edb9b5fe0fc1b4bb2b6

Github Repo : https://github.com/yhagio/meteor-tatter

Issue
When I click facebook login button, it opens the login popup, but the URL in the popup always shows that client_id=undefined, and gives "Sorry, something went wrong".

I installed service-configuration and accounts-facebook meteor packages and configured as follows. Also, cretead the app & added Facebook Login product in https://developers.facebook.com

Am I missing something?

Screenshot enter image description here

The URL is like this: https://www.facebook.com/v2.2/dialog/oauth?client_id=undefined&redirect_uri=http://localhost:3000/_oauth/facebook&display=popup&scope=public_profile&state=eyJsb2dpblN0eW...

In server https://github.com/yhagio/meteor-tatter/blob/master/imports/startup/server/index.js

import { Meteor } from 'meteor/meteor';
import { clientId, secret } from './secret.js';

Meteor.startup(() => {
  ServiceConfiguration.configurations.upsert(
    { service: "facebook" },
    {
      $set: {
        clientId: clientId,
        loginStyle: "popup",
        secret: secret
      }
    }
  );
});

In client https://github.com/yhagio/meteor-tatter/blob/master/imports/ui/helpers/auth.js

import { Meteor } from 'meteor/meteor';

export default function auth() {

  return new Promise((resolve, reject) => {
    Meteor.loginWithFacebook({
      requestPermissions: ['public_profile']
    }, (err, user) => {
      if (err !== null) return reject(err);
      resolve(user);
    });
  });
}

Solution

  • Problem was that it should be appId instead of clientId. Even though the guide shows clientId. Ref: http://docs.meteor.com/api/accounts.html#service-configuration