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

Function main

storage/getServiceAccount.js:22–54  ·  view source on GitHub ↗
(projectId = 'serviceAccountProjectId')

Source from the content-addressed store, hash-verified

20// usage: node getServiceAccount.js <PROJECT_ID>
21
22function main(projectId = 'serviceAccountProjectId') {
23 // [START storage_get_service_account]
24 /**
25 * TODO(developer): Uncomment the following lines before running the sample.
26 */
27 // The ID of your GCP project
28 // const projectId = 'your-project-id';
29
30 // Imports the Google Cloud client library
31 const {Storage} = require('@google-cloud/storage');
32
33 // Creates a client
34 const storage = new Storage({
35 projectId,
36 });
37
38 async function getServiceAccount() {
39 try {
40 const [serviceAccount] = await storage.getServiceAccount();
41 console.log(
42 `The GCS service account for project ${projectId} is: ${serviceAccount.emailAddress}`
43 );
44 } catch (error) {
45 console.error(
46 'Error executing get service account:',
47 error.message || error
48 );
49 }
50 }
51
52 getServiceAccount();
53 // [END storage_get_service_account]
54}
55main(...process.argv.slice(2));

Callers 1

Calls 1

getServiceAccountFunction · 0.85

Tested by

no test coverage detected