Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ async function main () {
});

// obtain the current project Id
const project = await google.auth.getDefaultProjectId();
const project = await google.auth.getProjectId();

// Fetch the list of GCE zones within a project.
const res = await compute.zones.list({ project, auth });
Expand Down Expand Up @@ -438,7 +438,7 @@ async function main() {
scopes: ['https://www.googleapis.com/auth/cloud-platform']
});

const projectId = await google.auth.getDefaultProjectId();
const projectId = await google.auth.getProjectId();

const request = {
projectId,
Expand Down
2 changes: 1 addition & 1 deletion samples/defaultauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async function main() {
});

// Obtain the current project Id
const project = await google.auth.getDefaultProjectId();
const project = await google.auth.getProjectId();

// Get the list of available compute zones for your project
const res = await compute.zones.list({project, auth});
Expand Down
41 changes: 0 additions & 41 deletions samples/directory_v1/README.md

This file was deleted.

10 changes: 0 additions & 10 deletions samples/directory_v1/authData.json

This file was deleted.

55 changes: 21 additions & 34 deletions samples/directory_v1/group-delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,43 +14,30 @@
'use strict';

const {google} = require('googleapis');
const nconf = require('nconf');
const path = require('path');

nconf
.argv()
.env()
.file(path.join(__dirname, '../jwt.keys.json'));
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',
],
});

// Create JWT auth object
const jwt = new google.auth.JWT(
nconf.get('client_email'),
null,
nconf.get('private_key'),
[
'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,
});

// Authorize
jwt.authorize((err, data) => {
if (err) {
throw err;
}
console.log('You have been successfully authenticated: ', data);
// delete the group key
const res = await admin.groups.delete({
groupKey: 'some_group@example.com',
});

// Get Google Admin API
const admin = google.admin('directory_v1');
console.log(res.data);
}

// Delete group
admin.groups.insert(
{
groupKey: 'some_group@example.com',
auth: jwt,
},
(err, data) => {
console.log(err || data);
}
);
});
runSample().catch(console.error);
57 changes: 22 additions & 35 deletions samples/directory_v1/group-email-delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,43 +15,30 @@

const {google} = require('googleapis');
const path = require('path');
const nconf = require('nconf');

nconf
.argv()
.env()
.file(path.join(__dirname, '../jwt.keys.json'));
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',
],
});

// Create JWT auth object
const jwt = new google.auth.JWT(
nconf.get('client_email'),
null,
nconf.get('private_key'),
[
'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,
});

// Authorize
jwt.authorize((err, data) => {
if (err) {
throw err;
}
console.log('You have been successfully authenticated: ', data);
// Delete member from Google group
const res = await admin.members.delete({
groupKey: 'my_group@example.com',
memberKey: 'me@example.com',
});

// Get Google Admin API
const admin = google.admin('directory_v1');
console.log(res.data);
}

// Delete member from Google group
admin.members.delete(
{
groupKey: 'my_group@example.com',
memberKey: 'me@example.com',
auth: jwt,
},
(err, data) => {
console.log(err || data);
}
);
});
runSample().catch(console.error);
59 changes: 24 additions & 35 deletions samples/directory_v1/group-email-insert.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,43 +15,32 @@

const {google} = require('googleapis');
const path = require('path');
const nconf = require('nconf');

nconf
.argv()
.env()
.file(path.join(__dirname, '../jwt.keys.json'));
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',
],
});

// Create JWT auth object
const jwt = new google.auth.JWT(
nconf.get('client_email'),
null,
nconf.get('private_key'),
[
'https://www.googleapis.com/auth/admin.directory.group',
'https://www.googleapis.com/auth/admin.directory.group.member',
]
);

// Authorize
jwt.authorize((err, data) => {
if (err) {
throw err;
}
console.log('You have been successfully authenticated: ', data);

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

// Insert member in Google group
admin.members.insert(
{
groupKey: 'my_group@example.com',
requestBody: {email: 'me@example.com'},
auth: jwt,
const res = await admin.members.insert({
groupKey: 'my_group@example.com',
requestBody: {
email: 'me@example.com',
},
(err, data) => {
console.log(err || data);
}
);
});
});

console.log(res.data);
}

runSample().catch(console.error);
57 changes: 23 additions & 34 deletions samples/directory_v1/group-insert.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,31 @@

const {google} = require('googleapis');
const path = require('path');
const nconf = require('nconf');

nconf
.argv()
.env()
.file(path.join(__dirname, '../jwt.keys.json'));
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',
],
});

// Create JWT auth object
const jwt = new google.auth.JWT(
nconf.get('client_email'),
null,
nconf.get('private_key'),
[
'https://www.googleapis.com/auth/admin.directory.group',
'https://www.googleapis.com/auth/admin.directory.group.member',
]
);

// Authorize
jwt.authorize((err, data) => {
if (err) {
throw err;
}
console.log('You have been successfully authenticated: ', data);

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

// Insert group
admin.groups.insert(
{
requestBody: {email: 'some_group@example.com'},
auth: jwt,
const res = await admin.groups.insert({
requestBody: {
email: 'some_group@example.com',
},
(err, data) => {
console.log(err || data);
}
);
});
});

console.log(res.data);
}

runSample().catch(console.error);