1

I'm asking if it's possible to retrieve the lists of meetings done with Google Hangout Meet API in Java?. After googling, I can't figure it out.

UPDATED - 1: With Google Calendar, I made:

        Calendar service = getCalendarService();
        List<Event> items = new ArrayList<Event>();
        String pageToken = null;
        do {
          Events events = service.events().list("service-account-esprit@my-first-project-2587777.iam.gserviceaccount.com").setPageToken(pageToken).execute();
          items = events.getItems();
          for (Event event : items) {
            System.out.println(event.getSummary());
          }
          pageToken = events.getNextPageToken();
        } while (pageToken != null);

Which the method getCredentials() is:

public static Credential getCredentials() throws IOException
{
    java.io.File clientSecretFilePath = new java.io.File(CREDENTIALS_FOLDER, CLIENT_SECRET_FILE_NAME);

    InputStream in = new FileInputStream(clientSecretFilePath);
    GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in));

    SCOPES.add(CalendarScopes.CALENDAR_READONLY);

    GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES).setDataStoreFactory(DATA_STORE_FACTORY).setAccessType("offline").build();
    Credential credential = new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user");

    return credential;
}

UPDATED - 2:

So, I missed enable G Suite domain wide delegation. I fixed that as presented by that capture I replaces the old credentials.json by my-first-project-274515-ba944be8b749.json (file resulted after creating the service account).

Then, I made Events events = service.events().list("service-account-esprit@my-first-project-2587777.iam.gserviceaccount.com").setPageToken(pageToken).execute();

I share the calendar with service-account-esprit@my-first-project-2587777.iam.gserviceaccount.com

I enabled Google calendar Api, too.

But I got that exception:

Exception in thread "main" java.lang.IllegalArgumentException at com.google.api.client.repackaged.com.google.common.base.Preconditions.checkArgument(Preconditions.java:108) at com.google.api.client.util.Preconditions.checkArgument(Preconditions.java:37) at com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets.getDetails(GoogleClientSecrets.java:82) at com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow$Builder.(GoogleAuthorizationCodeFlow.java:197) at tn.esprit.spring.google.calendar.Calendar_Utils.getCredentials(Calendar_Utils.java:75) at tn.esprit.spring.google.calendar.Calendar_Utils.getCalendarService(Calendar_Utils.java:87) at tn.esprit.spring.google.calendar.Calendar_Utils.main(Calendar_Utils.java:95)

--> I got error on GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES).setDataStoreFactory(DATA_STORE_FACTORY).setAccessType("offline").build(); I can't figure it out. Could you please tell me what I missed ?. Any suggestion is appreciated. Big thanks.

  • Do you mean Hangouts events that are created through a calendar event? – ziganotschka Apr 17 '20 at 07:39
  • Hello Sir @ziganotschka, thanks a lot for your reply. I mean each Meeting done with Google Meet API. But after googling, I know that there is no open Meet API. So, could you please tell me how can I retrieve the list of meetings done ?. it's possible to retrieve that list with Hangout ?. thanks again Sir. – misseoui nahla Apr 17 '20 at 08:13
  • Right now only possible if your meeting where created as a part of a calendar event. The hangouts API only lists chatrooms, which is different from meetings. – ziganotschka Apr 17 '20 at 10:59
  • Thanks a lot Sir for your reply. I tried retrieve all the events using Google Calendar API. I can do that with my own gmail account. But I failed to retrieve all the events with the domain (entreprise.tn : which contains a lot of gmail accounts). Could you please Sir tell me what I missed knowing that It works as well with Google Classroom API. Thanks a lot. – misseoui nahla Apr 17 '20 at 13:05
  • Can you post your code of how you did it for your gmail account? – ziganotschka Apr 17 '20 at 13:12
  • I share the code on my quetion. Could you please take a look ?. Big thanks Sir. – misseoui nahla Apr 17 '20 at 13:44
  • You are using a service account. Are you sure that the service account has viewing access to your corpCalendar? If not - you need to use impersonation. – ziganotschka Apr 17 '20 at 14:12
  • Yes Sir I did that, On **admin.google.com**, I have `Agenda Pas de restriction`. – misseoui nahla Apr 17 '20 at 14:45
  • What's `Agenda Pas de restriction`? Have you enabled on `admin.google.com` domain-wide delegation? Are you using for your corp account your corp service account? Did you give it the necessary scopes in `admin.google.com`? – ziganotschka Apr 17 '20 at 14:51
  • You're right Sir, thanks a lot for your guidance, All is done, as result I got the capture shared above, I made some modification on my question, Could you please - if you don't mind - take a look and tell me why I got that exception ?. – misseoui nahla Apr 18 '20 at 02:35
  • You need to specify the impersonated user with `.setServiceAccountUser(serviceAccountUser)` when you build `flow`. – ziganotschka Apr 20 '20 at 08:24

1 Answers1

2

You can try:

Events events = service.events().list(user@entreprise.tn)
                .setOrderBy("startTime")
                .setSingleEvents(true)
                .execute();

HTH.

Saria Essid
  • 1,240
  • 1
  • 11
  • 16