I am trying to get a list of google groups in my domain but getting: error 403 "Not Authorized to access this resource/api".
What am I doing wrong?
This is the node.js code I used:
const {google} = require('googleapis');
const path = require('path');
async function runSample() {
const auth = new google.auth.GoogleAuth({
keyFile: path.join(__dirname, 'service-account-super-admin.json'),
scopes: [
'https://www.googleapis.com/auth/admin.directory.group',
'https://www.googleapis.com/auth/admin.directory.group.member',
'https://apps-apis.google.com/a/feeds/groups/',
'https://www.googleapis.com/auth/admin.directory.group.readonly',
],
});
const admin = google.admin({
version: 'directory_v1',
auth,
});
let res
res = await admin.groups.list({ domain: "mydomain.com" });
}
runSample().catch(console.error);
Thanks in advance