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
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