From 170d18ff2e199998914f58beab9fd9acad7d7447 Mon Sep 17 00:00:00 2001 From: "F. Hinkelmann" Date: Mon, 12 Nov 2018 21:25:19 -0500 Subject: [PATCH] Update googleapis and auth (#882) --- kms/keys.js | 17 +++-------------- kms/package.json | 7 +++---- kms/quickstart.js | 17 +++-------------- 3 files changed, 9 insertions(+), 32 deletions(-) diff --git a/kms/keys.js b/kms/keys.js index 5bc443a744..9effd9edd8 100644 --- a/kms/keys.js +++ b/kms/keys.js @@ -1249,25 +1249,14 @@ function disableCryptoKeyVersion (projectId, locationId, keyRingId, cryptoKeyId, function buildAndAuthorizeService (callback) { // Imports the Google APIs client library - const {google} = require('googleapis'); + const { google } = require('googleapis'); // Acquires credentials - google.auth.getApplicationDefault((err, authClient) => { - if (err) { - callback(err); - return; - } - - if (authClient.createScopedRequired && authClient.createScopedRequired()) { - authClient = authClient.createScoped([ - 'https://www.googleapis.com/auth/cloud-platform' - ]); - } - + google.auth.getClient({ scopes: ['https://www.googleapis.com/auth/cloud-platform'] }).then(auth => { // Instantiates an authorized client const cloudkms = google.cloudkms({ version: 'v1', - auth: authClient + auth }); callback(null, cloudkms); diff --git a/kms/package.json b/kms/package.json index 2d1a32ec7b..b48d1278e9 100644 --- a/kms/package.json +++ b/kms/package.json @@ -17,16 +17,15 @@ "test": "repo-tools test run --cmd ava -- -T 20s --verbose system-test/*.test.js" }, "dependencies": { - "googleapis": "27.0.0", + "googleapis": "^35.0.0", "safe-buffer": "5.1.1", - "uuid": "^3.2.1", "yargs": "11.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", + "uuid": "^3.2.1" }, "cloud-repo-tools": { "requiresKeyFile": true, diff --git a/kms/quickstart.js b/kms/quickstart.js index ff95add002..aa3b78ad6b 100644 --- a/kms/quickstart.js +++ b/kms/quickstart.js @@ -17,7 +17,7 @@ // [START kms_quickstart] // Imports the Google APIs client library -const {google} = require('googleapis'); +const { google } = require('googleapis'); // Your Google Cloud Platform project ID const projectId = process.env.GCLOUD_PROJECT; @@ -26,22 +26,11 @@ const projectId = process.env.GCLOUD_PROJECT; const location = 'global'; // Acquires credentials -google.auth.getApplicationDefault((err, authClient) => { - if (err) { - console.error('Failed to acquire credentials'); - return; - } - - if (authClient.createScopedRequired && authClient.createScopedRequired()) { - authClient = authClient.createScoped([ - 'https://www.googleapis.com/auth/cloud-platform' - ]); - } - +google.auth.getClient({ scopes: ['https://www.googleapis.com/auth/cloud-platform'] }).then(auth => { // Instantiates an authorized client const cloudkms = google.cloudkms({ version: 'v1', - auth: authClient + auth }); const request = { parent: `projects/${projectId}/locations/${location}`