googleapis / googleapis/google-api-nodejs-client

API calls using Service account credentials

Open
#3,104 0 comments 0 reactions 0 assignees View on GitHub
priority: p3 type: question
Dominant language
TypeScript
Stars
12.2k
Forks
2k
Avg merge
1d 9h
Merged PRs (30d)
24

Description

Thanks for stopping by to ask us a question! Please make sure to include:
I am trying to make an API call using Service account credentials method in node backend

- async function main () {
const auth = new google.auth.GoogleAuth({
keyFile: 'mumzworldgoogle.json',
// Scopes can be specified either as an array or as a single, space-delimited string.
scopes: ['https://www.googleapis.com/auth/calendar.events']
});
const authClient = await auth.getClient();

// obtain the current project Id
const project = await auth.getProjectId();

// Fetch the list of GCE zones within a project.
const res = await compute.zones.list({ project, auth: authClient });
console.log(res.data);
}
router.get('/googleAPI', async (req, res) => {
main().catch(console.error);
})

I am getting an error TypeError: google.auth.GoogleAuth is not a constructor

**PLEASE READ**: If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/) instead of filing on GitHub. This will ensure a timely response.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.