Google meet api php example

When it comes to virtual meetings, the easiest way that comes to mind is Google Meet, just generate the meeting link and send it to the participants. But doing it over and over again is frustrating, so in this article, we discuss how we can automate this process and make it a feature of our product/software.

How to automate this process?

So for this purpose, we can use Google Meet API but the problem with this is that it does not exist. Although we can do it with the help of google calendar API it’s a little bit difficult for a beginner to understand.

Let’s build an unofficial API for google meet which is limited to generating meeting links.

Things required for this process:

Enable calendar API:

  • Client Id
  • Client Secret
  • Refresh Token

Don’t worry if you don’t know how to enable Calendar API and how to get them all, check out the video or follow the steps below:

https://media.geeksforgeeks.org/wp-content/uploads/20220106113608/Generating-client-Id-and-Client-Secret.mp4

Step 1: Visit the official website of google cloud console https://console.cloud.google.com

Step 2: If you are having an existing project then select that or click on a new project.

Step 3: Select the library tab, search for the calendar API and enable it.

Step 4: Select the credentials tab and create OAuth client ID.

Now we have the client id and client secret but still, the refresh token is missing.

Follow the step by step process:

For refresh token, we are going to use the passportJS google auth2.0.

Step 1: Do npm install:

  • express 
  • passport and,
  • passport-google-oauth20
npm install express passport passport-google-oauth20

Step 2: Add “https://www.googleapis.com/auth/calendar” to the scope for getting the token which have the access to your google calendar.

Step 3: Add your client Id and client secret and run the application. Access the server through your web browser so by this way you can get the refresh token. If you are stuck somewhere you can also check out the above video.

Javascript

const express = require('express');

const app = express();

const port = 8000;

const passport = require('passport');

var GoogleStrategy = require('passport-google-oauth20').Strategy;

clientID = "XXXXX7762268-71s6k9joXXXXX2p0a55ba8li85jXXXXX.apps.googleusercontent.com"

clientSecret = "XXXXPX-iXaXXXXXjcoGsnqYQr0rDJeXXXXX"

passport.use(new GoogleStrategy({

    clientID: clientID,

    clientSecret: clientSecret,

},

    function (accessToken, refreshToken, profile, cb) {

        console.log("refreshToken : ", refreshToken)

        return cb();

    }

));

app.get('/auth/callback',

    passport.authenticate('google', { failureRedirect: '/' })

);

app.get('/auth',

    passport.authenticate('google', {

        accessType: 'offline',

        prompt: 'consent'

    }

    ));

app.get('/', function (req, res) {

    res.send("done")

})

app.listen(port, function (err) {

    if (err) {

        console.log('something wrong in starting server !!!');

        return;

    }

    return console.log("server is up and running on port ", port);

});

Note

  • Replace the ‘X’ in the code with your Client Secret Key and Client ID to make it run.
  • After getting the refresh token you don’t need to do this process again and again.

Install one more npm package which was published by me google-meet-api and feed it all the details we have.

Javascript

const Meeting = require('google-meet-api').meet;

Meeting({

  clientId : 'XXXXdds420ghq7195tfsbi04i7rduaans.apps.googleusercontent.com',

  clientSecret : 'XXXXxxeh2mrCZ',

  refreshToken : 'XXXXXXXXXCNfW2MMGvJUSk4V7LplXAXXXX',

  date : "2020-12-01",

  time : "10:59",

  summary : 'summary',

  location : 'location',

  description : 'description'

  }).then(function(result){

  console.log(result);

})

Now the result is the final google meeting link here. Checkout full code here:

Github: https://github.com/sumitjangir123/Google-meeting-links

I’m assuming you enjoyed the article and found the material beneficial for your purposes.


Is there an API for Google Meet?

get() with applicationName=meet . You can use these parameters with this reports API to get details about the duration, number of participants, and device-specific characteristics of Meet calls, and general levels of Meet user activity across your organization.

Can we integrate Google Meet in your website?

Yes, Google Meet can be integrated with SeekLMS. However, only users with Google IDs will be able to join classes if GMeet is integrated.

How do I integrate Google Meet?

Start a meeting in the Meet app.
Open the Meet app ..
Tap New meeting..
Select an option: Get a meeting link to share: This generates a meeting link you can share to meet now or later. To invite others, tap Share invite. To join the meeting, copy the code into the "Join with a code" field..