Yasho Sagar
Yasho Sagar

Reputation: 123

Where should the service configuration go in meteor? At the client side or at the server side?

I'm working on a custom login-with-linkedin button. I have accounts-base, accounts-oauth, and pauli:accounts-linkedin packages. I have used the client id and the secret from the linkedin developers site as follows

Meteor.startup(function() {
    ServiceConfiguration.configurations.update({
        'service': 'linkedin',
    },
    {
        $set: {
            'clientId': 'myClientId',
            'secret': 'mySecret'
        }
    },
    {
        upsert: true
    });
});

In the iron router, I've also defined the waitOn function on /login template as follows:

this.route('login', {
    path: '/login',
    waitOn: function() {
       Accounts.loginServicesConfigured();
    }
});

Now, when I click on the button, a pop-up window opens but it doesn't load the linkedin login page and it says 'ERR_CONTENT_DECODING_FAILED'. enter image description here

I have written the ServiceConfiguration in the Meteor.startup function at the client side. Am I right to write serviceconfiguration at the client side? or should I be writing it at the server side?

Upvotes: 1

Views: 2044

Answers (2)

ApriOri
ApriOri

Reputation: 2688

It seems like there is a generic solution for this common issue

First, add the service configuration package:

meteor add service-configuration

Then, in your app:

ServiceConfiguration.configurations.upsert(
      { service: 'weibo' },
      {
        $set: {
          clientId: '1292962797',
          loginStyle: 'popup',
          secret: '75a730b58f5691de5522789070c319bc'
        }
      }
    );

I usually just put a service-config.js file with this code in the server.

Upvotes: 0

Kishor
Kishor

Reputation: 2677

It should be on the server-side. From the Meteor documentation here,

http://docs.meteor.com/#/full/meteor_loginwithexternalservice which says

Login service configuration is sent from the server to the client over DDP when your app starts up

I have done service configuration successfully for accounts-google on server side as well.

Upvotes: 2

Related Questions