From 02f444a97e2fd0a97af5680681594ad1f5ff7a7a Mon Sep 17 00:00:00 2001 From: Franziska Hinkelmann Date: Sun, 11 Nov 2018 19:53:52 -0500 Subject: [PATCH] Update jobs sample Update googleapis, use current auth. Refs: https://github.com/GoogleCloudPlatform/nodejs-docs-samples/issues/878 --- jobs/cjd_sample/package.json | 8 ++------ jobs/cjd_sample/quickstart.js | 19 +++---------------- 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/jobs/cjd_sample/package.json b/jobs/cjd_sample/package.json index 196b7c244e..a35a1894b9 100644 --- a/jobs/cjd_sample/package.json +++ b/jobs/cjd_sample/package.json @@ -17,15 +17,11 @@ "test": "repo-tools test run --cmd ava -- -T 20s --verbose system-test/*.test.js" }, "dependencies": { - "googleapis": "27.0.0", - "safe-buffer": "5.1.1", - "uuid": "^3.2.1", - "yargs": "11.0.0" + "googleapis": "^35.0.0" }, "devDependencies": { "@google-cloud/nodejs-repo-tools": "^3.0.0", "ava": "0.25.0", - "proxyquire": "2.0.1", - "semistandard": "^12.0.1" + "semistandard": "^13.0.1" } } diff --git a/jobs/cjd_sample/quickstart.js b/jobs/cjd_sample/quickstart.js index 8d9729a75e..acd28577ac 100755 --- a/jobs/cjd_sample/quickstart.js +++ b/jobs/cjd_sample/quickstart.js @@ -18,26 +18,13 @@ // [START quickstart] // Imports the Google APIs client library -const {google} = require('googleapis'); - -// Acquires credentials -google.auth.getApplicationDefault((err, authClient) => { - if (err) { - console.error('Failed to acquire credentials'); - console.error(err); - return; - } - - if (authClient.createScopedRequired && authClient.createScopedRequired()) { - authClient = authClient.createScoped([ - 'https://www.googleapis.com/auth/jobs' - ]); - } +const { google } = require('googleapis'); +google.auth.getClient({ scopes: ['https://www.googleapis.com/auth/jobs'] }).then((auth) => { // Instantiates an authorized client const jobs = google.jobs({ version: 'v2', - auth: authClient + auth }); // Lists companies