MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / authCloudImplicit

Function authCloudImplicit

auth/auth.js:22–48  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

20'use strict';
21
22const authCloudImplicit = async () => {
23 // [START auth_cloud_implicit]
24 // Imports the Google Cloud client library.
25 const {Storage} = require('@google-cloud/storage');
26
27 // Instantiates a client. If you don't specify credentials when constructing
28 // the client, the client library will look for credentials in the
29 // environment.
30 const storage = new Storage();
31 // Makes an authenticated API request.
32 async function listBuckets() {
33 try {
34 const results = await storage.getBuckets();
35
36 const [buckets] = results;
37
38 console.log('Buckets:');
39 buckets.forEach(bucket => {
40 console.log(bucket.name);
41 });
42 } catch (err) {
43 console.error('ERROR:', err);
44 }
45 }
46 listBuckets();
47 // [END auth_cloud_implicit]
48};
49
50const authCloudExplicit = async ({projectId, keyFilename}) => {
51 // [START auth_cloud_explicit]

Callers

nothing calls this directly

Calls 1

listBucketsFunction · 0.85

Tested by

no test coverage detected