Using Meteor, how do requestPermissions for Google Calendar with loginWithGoogle (without accounts-ui package)?

732 views Asked by At

I am building a Meteor application that requires access to a logged in user's Google Calendar account.

Currently I have Google Sign in on my login form (along with native account login) working. A user can sign in successfully using their Google Account.

I achieved the above as follows:

I installed the accounts-google and service-configuration packages. I already had the accounts-password package installed.

Next, I created a file in /server/lib/config called accounts.js that contains the following:

 Meteor.startup(function () {
  // Add Google configuration entry
  ServiceConfiguration.configurations.update(
    {service: "google"},
    {
      $set: {
        clientId: "*****.apps.googleusercontent.com",
        loginStyle: "popup",
        secret: "*****"
      }
    },
    {upsert: true}
  );
});

This allows a user to click on the Sign in with Google button, which renders a popup and allows them to sign in. Afterwards they are redirected to my app.

Now for (first) my question: how can I requestPermissions (as mentioned here in the official Accounts Docs) to access a user's Google Calendar? More specifically, where can I access the Accounts.LoginWithGoogle() method?

I have looked at other SO questions (such as this) explaining how to do it. However, they all use the accounts-ui package.

Also, how can I use the Google OAuth token I get from authentication offline (say, pass it to a Python script or having access to it via a MongoDB call)?

Any help would be greatly appreciated.

1

There are 1 answers

3
imslavko On

You can pass the same options as in the question you linked to to the Meteor.loginWithGoogle method.

Specifically, refer to this docs page: docs