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
6 changes: 3 additions & 3 deletions samples/analytics/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

const {google} = require('googleapis');
const path = require('path');
const {authenticate} = require('@google-cloud/local-auth');

const analytics = google.analytics('v3');

Expand All @@ -36,11 +35,12 @@ const variations = [

async function runSample() {
// Obtain user credentials to use for the request
const auth = await authenticate({
const auth = new google.auth.GoogleAuth({
keyfilePath: path.join(__dirname, '../oauth2.keys.json'),
scopes: 'https://www.googleapis.com/auth/analytics',
});
google.options({auth});
const client = await auth.getClient();
google.options({auth: client});

const res = await analytics.management.experiments.insert({
accountId: 'your-accountId',
Expand Down
6 changes: 3 additions & 3 deletions samples/analyticsReporting/batchGet.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@

const {google} = require('googleapis');
const path = require('path');
const {authenticate} = require('@google-cloud/local-auth');

const analyticsreporting = google.analyticsreporting('v4');

async function runSample() {
// Obtain user credentials to use for the request
const auth = await authenticate({
const auth = new google.auth.GoogleAuth({
keyfilePath: path.join(__dirname, '../oauth2.keys.json'),
scopes: 'https://www.googleapis.com/auth/analytics',
});
google.options({auth});
const client = await auth.getClient();
google.options({auth: client});

const res = await analyticsreporting.reports.batchGet({
requestBody: {
Expand Down
6 changes: 3 additions & 3 deletions samples/blogger/insert.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@

const path = require('path');
const {google} = require('googleapis');
const {authenticate} = require('@google-cloud/local-auth');

const blogger = google.blogger('v3');

async function runSample() {
// Obtain user credentials to use for the request
const auth = await authenticate({
const auth = new google.auth.GoogleAuth({
keyfilePath: path.join(__dirname, '../oauth2.keys.json'),
scopes: 'https://www.googleapis.com/auth/blogger',
});
google.options({auth});
const client = await auth.getClient();
google.options({auth: client});

const res = await blogger.posts.insert({
blogId: '4340475495955554224',
Expand Down
6 changes: 3 additions & 3 deletions samples/docs/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@

const path = require('path');
const {google} = require('googleapis');
const {authenticate} = require('@google-cloud/local-auth');

const docs = google.docs('v1');

async function runSample() {
// Obtain user credentials to use for the request
const auth = await authenticate({
const auth = new google.auth.GoogleAuth({
keyfilePath: path.join(__dirname, '../oauth2.keys.json'),
scopes: 'https://www.googleapis.com/auth/documents',
});
google.options({auth});
const client = await auth.getClient();
google.options({auth: client});

// The initial call to create the doc will have a title but no content.
// This is a limitation of the underlying API.
Expand Down
6 changes: 3 additions & 3 deletions samples/docs/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@
const path = require('path');
const util = require('util');
const {google} = require('googleapis');
const {authenticate} = require('@google-cloud/local-auth');

const docs = google.docs('v1');

async function runSample() {
// Obtain user credentials to use for the request
const auth = await authenticate({
const auth = new google.auth.GoogleAuth({
keyfilePath: path.join(__dirname, '../oauth2.keys.json'),
scopes: 'https://www.googleapis.com/auth/documents',
});
google.options({auth});
const client = await auth.getClient();
google.options({auth: client});

const res = await docs.documents.get({
documentId: '1XPbMENiP5bWP_cbqc0bEWbq78vmUf-rWQ6aB6FVZJyc',
Expand Down
6 changes: 3 additions & 3 deletions samples/drive/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@ const {google} = require('googleapis');
const fs = require('fs');
const os = require('os');
const path = require('path');
const {authenticate} = require('@google-cloud/local-auth');
const crypto = require('crypto');
const uuid = crypto.randomUUID();

const drive = google.drive('v3');

async function runSample(fileId) {
// Obtain user credentials to use for the request
const auth = await authenticate({
const auth = new google.auth.GoogleAuth({
keyfilePath: path.join(__dirname, '../oauth2.keys.json'),
scopes: [
'https://www.googleapis.com/auth/drive',
Expand All @@ -37,7 +36,8 @@ async function runSample(fileId) {
'https://www.googleapis.com/auth/drive.readonly',
],
});
google.options({auth});
const client = await auth.getClient();
google.options({auth: client});

// For converting document formats, and for downloading template
// documents, see the method drive.files.export():
Expand Down
6 changes: 3 additions & 3 deletions samples/drive/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ const {google} = require('googleapis');
const fs = require('fs');
const os = require('os');
const path = require('path');
const {authenticate} = require('@google-cloud/local-auth');

const drive = google.drive('v3');

async function runSample() {
// [START main_body]
// Obtain user credentials to use for the request
const auth = await authenticate({
const auth = new google.auth.GoogleAuth({
keyfilePath: path.join(__dirname, '../oauth2.keys.json'),
scopes: 'https://www.googleapis.com/auth/drive.readonly',
});
google.options({auth});
const client = await auth.getClient();
google.options({auth: client});

const fileId = '1EkgdLY3T-_9hWml0VssdDWQZLEc8qqpMB77Nvsx6khA';
const destPath = path.join(os.tmpdir(), 'important.pdf');
Expand Down
6 changes: 3 additions & 3 deletions samples/drive/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@

const path = require('path');
const {google} = require('googleapis');
const {authenticate} = require('@google-cloud/local-auth');

const drive = google.drive('v3');

async function runSample(query) {
// Obtain user credentials to use for the request
const auth = await authenticate({
const auth = new google.auth.GoogleAuth({
keyfilePath: path.join(__dirname, '../oauth2.keys.json'),
scopes: 'https://www.googleapis.com/auth/drive.metadata.readonly',
});
google.options({auth});
const client = await auth.getClient();
google.options({auth: client});

const params = {pageSize: 3};
params.q = query;
Expand Down
7 changes: 4 additions & 3 deletions samples/drive/quickstart.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@

// [START main_body]
const path = require('path');
const {authenticate} = require('@google-cloud/local-auth');
const {google} = require('googleapis');

/**
* Lists the names and IDs of up to 10 files.
*/
async function runSample() {
// Obtain user credentials to use for the request
const auth = await authenticate({
const auth = new google.auth.GoogleAuth({
keyfilePath: path.join(__dirname, '../oauth2.keys.json'),
scopes: 'https://www.googleapis.com/auth/drive.metadata.readonly',
});
google.options({auth});
const client = await auth.getClient();
google.options({auth: client});

const service = google.drive('v3');
const res = await service.files.list({
Expand All @@ -43,6 +43,7 @@ async function runSample() {
console.log(`${file.name} (${file.id})`);
}
}
return res.data;
}
if (module === require.main) {
runSample().catch(console.error);
Expand Down
6 changes: 3 additions & 3 deletions samples/drive/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ const fs = require('fs');
const path = require('path');
const readline = require('readline');
const {google} = require('googleapis');
const {authenticate} = require('@google-cloud/local-auth');

const drive = google.drive('v3');

async function runSample(fileName) {
// Obtain user credentials to use for the request
const auth = await authenticate({
const auth = new google.auth.GoogleAuth({
keyfilePath: path.join(__dirname, '../oauth2.keys.json'),
scopes: 'https://www.googleapis.com/auth/drive.file',
});
google.options({auth});
const client = await auth.getClient();
google.options({auth: client});

const fileSize = fs.statSync(fileName).size;
const res = await drive.files.create(
Expand Down
6 changes: 3 additions & 3 deletions samples/gmail/labels.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@

const path = require('path');
const {google} = require('googleapis');
const {authenticate} = require('@google-cloud/local-auth');

const gmail = google.gmail('v1');

async function runSample(action, messageId, labelId) {
// Obtain user credentials to use for the request
const auth = await authenticate({
const auth = new google.auth.GoogleAuth({
keyfilePath: path.join(__dirname, '../oauth2.keys.json'),
scopes: 'https://www.googleapis.com/auth/gmail.modify',
});
google.options({auth});
const client = await auth.getClient();
google.options({auth: client});

if (action === 'add') {
const res = await gmail.users.messages.modify({
Expand Down
6 changes: 3 additions & 3 deletions samples/gmail/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@

const path = require('path');
const {google} = require('googleapis');
const {authenticate} = require('@google-cloud/local-auth');

const gmail = google.gmail('v1');

async function runSample() {
// Obtain user credentials to use for the request
const auth = await authenticate({
const auth = new google.auth.GoogleAuth({
keyfilePath: path.join(__dirname, '../oauth2.keys.json'),
scopes: 'https://www.googleapis.com/auth/gmail.readonly',
});
google.options({auth});
const client = await auth.getClient();
google.options({auth: client});

const res = await gmail.users.messages.list({userId: 'me'});
console.log(res.data);
Expand Down
6 changes: 3 additions & 3 deletions samples/gmail/send.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@

const path = require('path');
const {google} = require('googleapis');
const {authenticate} = require('@google-cloud/local-auth');

const gmail = google.gmail('v1');

async function runSample() {
// Obtain user credentials to use for the request
const auth = await authenticate({
const auth = new google.auth.GoogleAuth({
keyfilePath: path.join(__dirname, '../oauth2.keys.json'),
scopes: [
'https://mail.google.com/',
Expand All @@ -30,7 +29,8 @@ async function runSample() {
'https://www.googleapis.com/auth/gmail.send',
],
});
google.options({auth});
const client = await auth.getClient();
google.options({auth: client});

// You can use UTF-8 encoding for the subject using the method below.
// You can also just use a plain string if you don't need anything fancy.
Expand Down
6 changes: 3 additions & 3 deletions samples/gmail/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

const path = require('path');
const {google} = require('googleapis');
const {authenticate} = require('@google-cloud/local-auth');

const gmail = google.gmail('v1');

Expand All @@ -32,7 +31,7 @@ const gmail = google.gmail('v1');
*/
async function runSample() {
// Obtain user credentials to use for the request
const auth = await authenticate({
const auth = new google.auth.GoogleAuth({
keyfilePath: path.join(__dirname, '../oauth2.keys.json'),
scopes: [
'https://mail.google.com/',
Expand All @@ -41,7 +40,8 @@ async function runSample() {
'https://www.googleapis.com/auth/gmail.readonly',
],
});
google.options({auth});
const client = await auth.getClient();
google.options({auth: client});

const res = await gmail.users.watch({
userId: 'me',
Expand Down
6 changes: 3 additions & 3 deletions samples/jobs/jobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@

const path = require('path');
const {google} = require('googleapis');
const {authenticate} = require('@google-cloud/local-auth');

const jobService = google.jobs('v3');

async function runSample() {
// Obtain user credentials to use for the request
const auth = await authenticate({
const auth = new google.auth.GoogleAuth({
keyfilePath: path.join(__dirname, '../oauth2.keys.json'),
scopes: [
'https://www.googleapis.com/auth/jobs',
'https://www.googleapis.com/auth/cloud-platform',
],
});
google.options({auth});
const client = await auth.getClient();
google.options({auth: client});

const projectId = await google.auth.getProjectId();
const res = await jobService.projects.companies.create({
Expand Down
6 changes: 3 additions & 3 deletions samples/mediaupload.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@

const {google} = require('googleapis');
const path = require('path');
const {authenticate} = require('@google-cloud/local-auth');

const drive = google.drive('v3');

async function runSamples() {
// Obtain user credentials to use for the request
const auth = await authenticate({
const auth = new google.auth.GoogleAuth({
keyfilePath: path.join(__dirname, '../oauth2.keys.json'),
scopes: [
'https://www.googleapis.com/auth/drive.metadata',
'https://www.googleapis.com/auth/drive.photos',
'https://www.googleapis.com/auth/drive',
],
});
google.options({auth});
const client = await auth.getClient();
google.options({auth: client});

// insertion example
let res = await drive.files.insert({
Expand Down
6 changes: 3 additions & 3 deletions samples/mirror/mirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@

const path = require('path');
const {google} = require('googleapis');
const {authenticate} = require('@google-cloud/local-auth');

// initialize the Google Mirror API library
const mirror = google.mirror('v1');

// a very simple example of listing locations from the mirror API
async function runSample() {
// Obtain user credentials to use for the request
const auth = await authenticate({
const auth = new google.auth.GoogleAuth({
keyfilePath: path.join(__dirname, '../oauth2.keys.json'),
scopes: [
'https://www.googleapis.com/auth/glass.timeline',
'https://www.googleapis.com/auth/glass.location',
],
});
google.options({auth});
const client = await auth.getClient();
google.options({auth: client});

const res = await mirror.locations.list({});
console.log(res.data);
Expand Down
Loading
Loading