How to use the googleapis.google.admin function in googleapis

To help you get started, we’ve selected a few googleapis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github googleapis / google-api-nodejs-client / samples / directory_v1 / group-insert.js View on Github external
async function runSample() {
  // acquire an authentication client using a service account
  const auth = await google.auth.getClient({
    keyFile: path.join(__dirname, '../jwt.keys.json'),
    scopes: [
      'https://www.googleapis.com/auth/admin.directory.group',
      'https://www.googleapis.com/auth/admin.directory.group.member',
    ],
  });

  // obtain the admin client
  const admin = google.admin({
    version: 'directory_v1',
    auth,
  });

  // Insert group
  const res = await admin.groups.insert({
    requestBody: {
      email: 'some_group@example.com',
    },
  });

  console.log(res.data);
}
github googleapis / google-api-nodejs-client / samples / directory_v1 / group-delete.js View on Github external
async function runSample() {
  // acquire an authentication client using a service account
  const auth = await google.auth.getClient({
    keyFile: path.join(__dirname, '../jwt.keys.json'),
    scopes: [
      'https://www.googleapis.com/auth/admin.directory.group',
      'https://www.googleapis.com/auth/admin.directory.group.member',
    ],
  });

  // obtain the admin client
  const admin = google.admin({
    version: 'directory_v1',
    auth,
  });

  // delete the group key
  const res = await admin.groups.delete({
    groupKey: 'some_group@example.com',
  });

  console.log(res.data);
}
github googleapis / google-api-nodejs-client / samples / directory_v1 / group-email-delete.js View on Github external
async function runSample() {
  // acquire an authentication client using a service account
  const auth = await google.auth.getClient({
    keyFile: path.join(__dirname, '../jwt.keys.json'),
    scopes: [
      'https://www.googleapis.com/auth/admin.directory.group',
      'https://www.googleapis.com/auth/admin.directory.group.member',
    ],
  });

  // obtain the admin client
  const admin = google.admin({
    version: 'directory_v1',
    auth,
  });

  // Delete member from Google group
  const res = await admin.members.delete({
    groupKey: 'my_group@example.com',
    memberKey: 'me@example.com',
  });

  console.log(res.data);
}
github googleapis / google-api-nodejs-client / samples / directory_v1 / group-email-insert.js View on Github external
async function runSample() {
  // acquire an authentication client using a service account
  const auth = await google.auth.getClient({
    keyFile: path.join(__dirname, '../jwt.keys.json'),
    scopes: [
      'https://www.googleapis.com/auth/admin.directory.group',
      'https://www.googleapis.com/auth/admin.directory.group.member',
    ],
  });

  // obtain the admin client
  const admin = google.admin({
    version: 'directory_v1',
    auth,
  });

  // Insert member in Google group
  const res = await admin.members.insert({
    groupKey: 'my_group@example.com',
    requestBody: {
      email: 'me@example.com',
    },
  });

  console.log(res.data);
}
github gsuitedevs / node-samples / adminSDK / directory / index.js View on Github external
function listUsers(auth) {
  const service = google.admin({version: 'directory_v1', auth});
  service.users.list({
    customer: 'my_customer',
    maxResults: 10,
    orderBy: 'email',
  }, (err, res) => {
    if (err) return console.error('The API returned an error:', err.message);

    const users = res.data.users;
    if (users.length) {
      console.log('Users:');
      users.forEach((user) => {
        console.log(`${user.primaryEmail} (${user.name.fullName})`);
      });
    } else {
      console.log('No users found.');
    }
github gsuitedevs / node-samples / adminSDK / reports / index.js View on Github external
function listLoginEvents(auth) {
  const service = google.admin({version: 'reports_v1', auth});
  service.activities.list({
    userKey: 'all',
    applicationName: 'login',
    maxResults: 10,
  }, (err, res) => {
    if (err) return console.error('The API returned an error:', err.message);

    const activities = res.data.items;
    if (activities.length) {
      console.log('Logins:');
      activities.forEach((activity) => {
        console.log(`${activity.id.time}: ${activity.actor.email} (${activity.events[0].name})`);
      });
    } else {
      console.log('No logins found.');
    }
github bitwarden / directory-connector / src / services / gsuite-directory.service.ts View on Github external
constructor(private configurationService: ConfigurationService, private logService: LogService,
        private i18nService: I18nService) {
        super();
        this.service = google.admin('directory_v1');
    }