Skip to content

Commit

Permalink
Update googleapis and auth (#882)
Browse files Browse the repository at this point in the history
  • Loading branch information
fhinkel authored Nov 13, 2018
1 parent ed7445f commit 170d18f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 32 deletions.
17 changes: 3 additions & 14 deletions kms/keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 3 additions & 4 deletions kms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
17 changes: 3 additions & 14 deletions kms/quickstart.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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}`
Expand Down

0 comments on commit 170d18f

Please sign in to comment.