Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

98
Vistas
How do you leave a googlegroup via the Googlescript API

What I am trying to do is leave a googlegroup by utilizing the API rather then having to click on the group itself. This is not shown in the API documentation located here: Google Groups API

In trying to find a way to leave a group via the API I did find out I was a member of different groups that I did not join but it appears there is no documented way of leaving them. Going here: Enum Role. This allows me to see what role I have within a group and the corresponding code used is below.

There is a Enterprise Admin API for removing a group membership but this is not a Enterprise setup and thus AdminGroupSettings cannot be used in this scope.

function getGroupNames() {

  try {
      var groups = GroupsApp.getGroups();
  }
  catch(err) {
      console.log("Permission error [getGroup]: Cannot access group members list!");
  }
  
  for (var i = 0; i < groups.length; i++) {
    var group = groups[i];
    var currentUser = Session.getActiveUser();
    // https://stackoverflow.com/questions/62801809/in-google-app-scripts-how-can-you-get-the-group-name-with-the-group-email
    // Groups Settings API/AdminGroupSettings
    // var groupName = AdminGroupsSettings.Groups.get('unsubscribe-me500@arefilled.site').name;
    // console.log("Attempting to get group name: " + groupName + " from address " + groups[i]);
    if (group.getRole(currentUser.getEmail()) == GroupsApp.Role.MEMBER){
        // How to leave group??
        console.log('You are a member of ' + group.getEmail()); 
        continue;
    }
    if (group.getRole(group.getEmail()) == GroupsApp.Role.INVITED){
        // leave group
        console.log('You are invited to ' + group.getEmail());
        continue;
    }
    if (group.getRole(group.getEmail()) == GroupsApp.Role.MANAGER){
        console.log('You are manager of ' + group.getEmail());
        continue;
    }
    if (group.getRole(group.getEmail()) == GroupsApp.Role.OWNER){
        // leave group
        console.log('You are owner of ' + group.getEmail());
        continue;
    }    
      if (group.getRole(group.getEmail()) == GroupsApp.Role.PENDING){
        // leave group
        console.log('You are pending to ' + group.getEmail());
        continue;
    }
  }

}

Is it possible to leave a group via Google Groups API? If so, how?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Answer:

You need to use the Admin SDK Directory API to remove a member from a group.

More Infomation:

The Directory API has a members.delete method which allows you to remove a member from a Google Group.

In Apps Script, you will need to add the AdminDirectory Advanced service to the project, and specify the groupKey of the group and the membersKey of the member you wish to remove in the request:

const groupKey = "XXXXXXXXX"
const memberKey = "YYYYYY"

AdminDirectory.Members.remove(groupKey, memberKey)

A successful deletion will result in an HTTP 204 reponse.

NB: You need to run this code as a domain Admin. It is not possible to remove a member from a Google Group via the API without using the Admin SDK.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda